By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,317 Members | 1,303 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,317 IT Pros & Developers. It's quick & easy.

what am I missing in my update command? table wont update

P: n/a
Private Sub UpdateTblHistory()
Dim strSql As String

strSql = "Update tbl_History set SubscrID = @SubscrID Where ID = @ID"

da.UpdateCommand.CommandText = strSql
da.UpdateCommand.Parameters.Add("@SubscrID", SqlDbType.VarChar, 50,
"SubscrID")
da.UpdateCommand.Parameters.Add("@ID", SqlDbType.Int, 4, "ID")
da.Update(ds, "tbl_History")
End Sub
----------------------------------------------------------------------------------

I am displaying a row from tbl_History in a datagridview. In the
datagridview_CellValueChanged event I call the update procedure above. The
code runs but tbl_History is not getting updated. Can anyone see why
tbl_History wont update?

Thanks,
Rich
Jul 18 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Well, I added the following code to my update procedure. Now it updates, but
isnt' it supposed to be simpler than this?

---------------------------------------------------------
Private Sub UpdateTblHistory()
Dim strSql, str1 As String

For Each dr As DataRow In ds.Tables("tbl_History").Rows
If dr.RowState = DataRowState.Modified Then
str1 = dr("SubscrID").ToString
dr.BeginEdit()
dr("SubscrID") = str1
dr.EndEdit()
End If
Next

strSql = "Update tbl_History set SubscrID = @SubscrID Where ID = @ID"

da.UpdateCommand.CommandText = strSql
da.UpdateCommand.Parameters.Add("@SubscrID", SqlDbType.VarChar, 50,
"SubscrID")
da.UpdateCommand.Parameters.Add("@ID", SqlDbType.Int, 4, "ID")
da.Update(ds, "tbl_History")
End Sub
-----------------------------------------------------------------

"Rich" wrote:
Private Sub UpdateTblHistory()
Dim strSql As String

strSql = "Update tbl_History set SubscrID = @SubscrID Where ID = @ID"

da.UpdateCommand.CommandText = strSql
da.UpdateCommand.Parameters.Add("@SubscrID", SqlDbType.VarChar, 50,
"SubscrID")
da.UpdateCommand.Parameters.Add("@ID", SqlDbType.Int, 4, "ID")
da.Update(ds, "tbl_History")
End Sub
----------------------------------------------------------------------------------

I am displaying a row from tbl_History in a datagridview. In the
datagridview_CellValueChanged event I call the update procedure above. The
code runs but tbl_History is not getting updated. Can anyone see why
tbl_History wont update?

Thanks,
Rich
Jul 18 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.