Stuck in saving Records in DB using ADO.Net (RESOLVED)
I am editing a specific column of a DataRow using Item collection.. then i am using DataAdapter's Update method to save the changes but it is giving me
System.InvalidOperationException: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
Now how can i know the update command for this row@ run time? I am lost:(
Well.. I am new to Ado.Net and VB.Net......
***Believe me.. I used to be a VB GURU***:( :( :( :( :( :( :( :( :(
Re: Stuck in saving Records in DB using ADO.Net
Quote:
Originally posted by moinkhan
I am editing a specific column of a DataRow using Item collection.. then i am using DataAdapter's Update method to save the changes but it is giving me
System.InvalidOperationException: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
Now how can i know the update command for this row@ run time? I am lost:(
Well.. I am new to Ado.Net and VB.Net......
***Believe me.. I used to be a VB GURU***:( :( :( :( :( :( :( :( :(
Post some code so we can see what you are doing wrong. Its more than likely that you did not specify an update command.
Stuck in saving Records in DB using ADO.Net(RESOLVED)
Thanx.. It's resovled..
By the hints from u ppl i wrote the following Code....
and it worked...:D
Thanx everybody
Wallabie!! your GetUpdateCommand seemed to do the trick.. Thanx....
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = F:\Moin\.Net Products\EditingDataSet\temp.mdb"
con.Open()
cmd.Connection = con
cmd.CommandText = "Select * from Crime"
da.SelectCommand = cmd
da.Fill(ds, "Crime")
Dim cmdBuilder As New OleDbCommandBuilder(da)
ds.Tables(0).Rows(0).Item("Doer") = "Salman Talpur Achakzai"
da.UpdateCommand = cmdBuilder.GetUpdateCommand
da.Update(ds, "Crime")
End Sub
End Class
:D