Hi.
I have datagrid and a button in my wpf window. I' d like to update my database after user make changes in datagrid.
But instead of update I'm getting "the UpdateCommand affected 0 of the expected 1 records." error.
If i comment a line number 19 I get a "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." error
My database file in SQLITE has a primary key. I spent couple days and I've no idea what is wrong with my code.
I hope someone help me and indicate my mistakes.
Best Regards
This is my code :
------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------
I have datagrid and a button in my wpf window. I' d like to update my database after user make changes in datagrid.
But instead of update I'm getting "the UpdateCommand affected 0 of the expected 1 records." error.
If i comment a line number 19 I get a "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." error
My database file in SQLITE has a primary key. I spent couple days and I've no idea what is wrong with my code.
I hope someone help me and indicate my mistakes.
Best Regards
This is my code :
------------------------------------------------------------------------------------------------------------------
- Class MainWindow
- Public con As New System.Data.SQLite.SQLiteConnection("Data Source = C:\database.s3db")
- Public da As New System.Data.SQLite.SQLiteDataAdapter("Select * from Customers", con)
- Public ds As New System.Data.DataSet
- Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
- con.Open()
- da.Fill(ds, "Customers")
- con.Close()
- datagridCustomers.ItemsSource = ds.Tables("Customers").DefaultView
- End Sub
- Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnUpdate.Click
- Dim cb As New System.Data.SQLite.SQLiteCommandBuilder(da)
- da.Update(ds, "Customers")
- End Sub
- End Class
-----------------------------------------------------------------------------------------------------------------