G
Guest
I am using OleDbDataAdapter in order to fill a data table and update it.
The fill method is working fine but the update does not work, and I dont
know why.
Here is my code:
Dim data_table As DataTable
Dim conn As OleDbConnection
Dim data_adapter As OleDbDataAdapter
conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=
test_db.mdb")
conn.Open()
data_adapter = New OleDbDataAdapter("select * from test_table", conn)
data_table = New DataTable
data_adapter.Fill(data_table)
Me.DataGridView1.DataSource = data_table
'do some changes on the datagridview
Dim temp_val As String = data_table.Rows(row_index)(col_index)
data_adapter.UpdateCommand = New OleDbCommand("update test_table set minimum
= '" & temp_val & "' where growth_day = 1", conn)
data_adapter.Update(data_table)
conn.Close()
minimum and growth_day are fields in my database wich growth_day is the key.
I think the code is ok but the database stays the same and does not accept
the changes. Can someone please help me and tell why does the update is not
working?
I am using VS2005.
The fill method is working fine but the update does not work, and I dont
know why.
Here is my code:
Dim data_table As DataTable
Dim conn As OleDbConnection
Dim data_adapter As OleDbDataAdapter
conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=
test_db.mdb")
conn.Open()
data_adapter = New OleDbDataAdapter("select * from test_table", conn)
data_table = New DataTable
data_adapter.Fill(data_table)
Me.DataGridView1.DataSource = data_table
'do some changes on the datagridview
Dim temp_val As String = data_table.Rows(row_index)(col_index)
data_adapter.UpdateCommand = New OleDbCommand("update test_table set minimum
= '" & temp_val & "' where growth_day = 1", conn)
data_adapter.Update(data_table)
conn.Close()
minimum and growth_day are fields in my database wich growth_day is the key.
I think the code is ok but the database stays the same and does not accept
the changes. Can someone please help me and tell why does the update is not
working?
I am using VS2005.