update problem
-
hi smile.gif i have the fellowing code for updating the database when its change in data grid
While (r < DataGridView1.Rows.Count - 1) InsertCommand1.Parameters.Clear() InsertCommand1.CommandText = "UPDATE [Section] SET Capacity =" & DataGridView1.Rows(r).Cells(2).Value & " WHERE SectionID = " & DataGridView1.Rows(r).Cells(1).Value InsertCommand1.CommandType = CommandType.Text InsertCommand1 = InsertCommand1 DataAdapter1.InsertCommand = InsertCommand1 InsertCommand1.ExecuteNonQuery() DataAdapter1.Update(DataSet1, "Section") r += 1 End While
it make the update but it give the fellowing error Update requires a valid UpdateCommand when passed DataRow collection with modified rows. when i but the fellowing command Dim CmdB As New OleDb.OleDbCommandBuilder(DataAdapter1) it give error in update statment -
hi smile.gif i have the fellowing code for updating the database when its change in data grid
While (r < DataGridView1.Rows.Count - 1) InsertCommand1.Parameters.Clear() InsertCommand1.CommandText = "UPDATE [Section] SET Capacity =" & DataGridView1.Rows(r).Cells(2).Value & " WHERE SectionID = " & DataGridView1.Rows(r).Cells(1).Value InsertCommand1.CommandType = CommandType.Text InsertCommand1 = InsertCommand1 DataAdapter1.InsertCommand = InsertCommand1 InsertCommand1.ExecuteNonQuery() DataAdapter1.Update(DataSet1, "Section") r += 1 End While
it make the update but it give the fellowing error Update requires a valid UpdateCommand when passed DataRow collection with modified rows. when i but the fellowing command Dim CmdB As New OleDb.OleDbCommandBuilder(DataAdapter1) it give error in update statmentasha_s wrote:
Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
These built in update things suck. However, if you must use them, this error is telling you that you need to specify the update command ( the SQL that does the update )
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
asha_s wrote:
Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
These built in update things suck. However, if you must use them, this error is telling you that you need to specify the update command ( the SQL that does the update )
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
Christian Graus wrote:
this error is telling you that you need to specify the update command ( the SQL that does the update )
how can i specify it i am sure from the type of the sended perimeter if you have another way rather than command please tell me :(( :((