I'd like to ask for your help for a problem I am facing in .NET . Recently I decided to work with data bases (Access files) , but it seems I am going to need help in order to succeed it that !
I have placed a DataGridView control on a form of mine and what I wish is to update the data base file after I made a change in one of the DataGridView's entries . I am using this code :
'Binding the DataGridView control to a data source of a data base file :
Dim DataBaseConnectionMY As New OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source="C:\AAA\aaa.mdb")
Dim DataAdapterMY As New OleDb.OleDbDataAdapter("SELECT * FROM Companies", DataBaseConnectionMY)
Dim DataSetMY As New DataSet
DataBaseConnectionMY.Open()
DataAdapterMY.Fill(DataSetMY, "Companies")
DataBaseConnectionMY.Close()
DataGridViewMY.DataSource = DataSetMY
DataGridViewMY.DataMember = "Companies"
'Saving the changes in the data base file :
Dim CommandBuilderMY As New OleDb.OleDbCommandBuilder(DataAdapterMY)
CommandBuilderMY.GetUpdateCommand()
DataAdapterMY.Update(DataSetMY, "Companies")
but it seems that I am doing something wrong , because once I press the button to run the above code , the DataGridView reloads the table from the data base file but it is the same as before (no change incorporated) .
I have placed a DataGridView control on a form of mine and what I wish is to update the data base file after I made a change in one of the DataGridView's entries . I am using this code :
'Binding the DataGridView control to a data source of a data base file :
Dim DataBaseConnectionMY As New OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source="C:\AAA\aaa.mdb")
Dim DataAdapterMY As New OleDb.OleDbDataAdapter("SELECT * FROM Companies", DataBaseConnectionMY)
Dim DataSetMY As New DataSet
DataBaseConnectionMY.Open()
DataAdapterMY.Fill(DataSetMY, "Companies")
DataBaseConnectionMY.Close()
DataGridViewMY.DataSource = DataSetMY
DataGridViewMY.DataMember = "Companies"
'Saving the changes in the data base file :
Dim CommandBuilderMY As New OleDb.OleDbCommandBuilder(DataAdapterMY)
CommandBuilderMY.GetUpdateCommand()
DataAdapterMY.Update(DataSetMY, "Companies")
but it seems that I am doing something wrong , because once I press the button to run the above code , the DataGridView reloads the table from the data base file but it is the same as before (no change incorporated) .