473,320 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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
1 1611
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: btober | last post by:
I run the following script to export some data from my development database and then update or insert the records into to the quality assurance testing database, but I get a warning notice that I...
3
by: Natthera | last post by:
Writing this for a webpage using ASP. I simply want to update to fields in an Access 2000 DB: sqlString = "UPDATE dialup SET password = '" & password & "' , username = '" & username & "' WHERE k...
3
by: LP | last post by:
Hello, In the past I used SqlCommandBuilder and SqlDataAdapter .Update method to apply changes in a DataTable back to its table source in SQL Server. It worked fine when DataSet had only 1...
2
by: Agnes | last post by:
I got a table which without primary key. case 1) I can process insertcommand and daMytable.update..etc case 2) However, if i process updatecommand , As I run daMytable.update .It returns error...
2
by: TJ | last post by:
Hi All, I am having some trouble. I have created a database via the new database option inside VWD2005. Then and table or two. I have been able to perform INSERT and SELECT operations on...
2
by: travhale | last post by:
in a new project using .net 2005, c#. getting err message "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." source RDBMS is oracle 8i. I add a new...
16
by: SLIMSHIM | last post by:
Hi, I"m new to c# and .net. I wrote a small program to add rows to an access table. the program goes thru the motions but the data never gets there. here is my code. I am intentionaly not using...
3
by: iKiLL | last post by:
Hi all The Code is below but i will give you a brief over view first. I am using C#, SQL Mobile and the CF2.0 with Merge Replication. My Primary Keys are all "uniqueidentifier" types...
13
by: Terry Olsen | last post by:
I'm using OleDb to connect with an Access Database. I have anywhere from 10 to over 100 records that I need to either INSERT if the PK doesn't exist or UPDATE if the PK does exist, all in a single...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.