General information
Title:
Update Sql Table Using VB
Hi,
What would be the code to update two fields in a SQL Table using VB.net?
Below is what I would like to do but I know the code is totally incorrect.
Sample Customer table - CustomerId int
CustomerName varchar
Address varchar
City varchar
State varchar
Sample Order table - CustomerId int
OrderID int
Processed bit
Shipped bit
DateShipped datetime
I want to be able to update the SQL Order Table using Sql Commands in VB.
Update field Shipped with 1
field DateShipped with today's date
Created SqlDataAdapter1 Using Query Wizard - Customer Table, Orders Table
Selected Fields CustomerId,CustomerName,Address,City,State,OrderId
Created OrdersToBeProcessedDataset
strUpdateCommand = "UPDATE _______________" ' Need Proper Code Here
Open Connection
Dim myDataRow As DataRow
For Each myDataRow In OrdersToBeProcessedDataset.Tables("Orders").Rows
' initialize fields with values
Processed = 1 ' Need Proper Code Here
DateProcessed = NOW() ' Need Proper Code Here
UpdateCMD.ExecuteNonQuery()
next
Close Connection
Any error code to make sure the updates are processed would also be appreciated.
Is this an acceptable way to Update Sql Tables or is there a better way?
Thanks
Roland
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only