DataAdapter.Update Problem
Database
1
Posts
1
Posters
0
Views
1
Watching
-
Hi I use the following code to add a row to my database using ADO.NET in VB.NET:
Dim strConnstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\DB.mdb" Dim Sql As String = String.Format("INSERT INTO Employee(FName,LName,Salary) VALUES('{0}','{1}',{2})", txtFirstName.Text, txtLastName.Text, txtSalary2.Text) Dim Conn As New OleDbConnection(strConnstring) Dim Comm As New OleDbCommand(Sql, Conn) Dim DA As New OleDbDataAdapter(Comm) Dim DS As New DataSet Conn.Open() Comm.ExecuteNonQuery() Conn.Close()
Everything looks fine, the datagrid which shows Employee table, shows that the item is added. But DataAdapter does not update the dataset! I noticed that when I add a row by this method, the State of the row is not set to Added, like when I use
Rows.Add
(which works just fine!) I need to do this using this SQL command, but how to update the database also? (I again notice that myDataSet.GetChanged is null!)