Hello everyone!
Ive seen many differnent answers and solutions for this question, but mine is a little different...
What I have is 2 different variables (1 string & 1 integer)... I want to place those two variables as data in an existing datarow in my sql db.
I can add them as another row no problem... but i have a row of data already partially filled and want to add these two values into the two NULL parts of that existing data row...
Any suggestions or hints (actual code would be nicer) would be greatly appreciated. Im actually starting to get this VB programming down- sorta.

VB The usual sql update data row problem
Craig0111
Dim dcString as new DataColumn("MyString")
Dim dcNumber as new DataColumn("MyInteger")
dt.columns.add(dcstring) ' assumes dt is the name of your datatable
dc.columns.add(dcNumber)
zaph
Your command text is broken - it looks like you have modified an INSERT clause... Below is a sample UPDATE clause:
Please note that this is far from the only possible way to update things - see http://msdn2.microsoft.com/en-us/library/ms177523(SQL.90).aspx for a more complete but more complex description and some examples...
Best regards,
Johan Stenberg
ivanL
Thanks! That really worked well for me...
Duane Douglas
Actually, the two columns are already set up and are NULL, they are in the middle of the row.
I just need to fill in those two columns on that same row somehow with the two variables or objects that I have in my code...
I did however enter this code and got an error that I cannot figure out why, because I followed the video directions carefully...
Dim
connectionString As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MechData.mdf;Integrated Security=True;User Instance=True" Dim connection As New SqlConnection(connectionString)connection.Open()
Dim cmd As SqlCommand = New SqlCommand() Dim irowsaffected As Integercmd.CommandType = CommandType.Text
cmd.CommandText =
"UPDATE playerinfo (MechNo, MechName) VALUE ('1', 'Raven')"cmd.Connection = connection
irowsaffected = cmd.ExecuteNonQuery()
MsgBox(irowsaffected)
connection.Close()
I get this error on irowsaffected = cmd.ExecuteNonQuery()
Incorrect syntax near '('.