J
Jerry
Greeting,
I am trying to update a detail table that does not have a
unique key (that is the exercise). With the code below I
am getting the error message "Incorrect syntax near
keyword Set" (note: sql code is all on one line). I may
be guilty of tring to use Com ADO syntax. In the Where
clause I am using declared variables instead of parameter
vars. Is that my error? Please could someone correct my
syntax error below?
----------------------------------------------------------
setting intID, str1 and str2 up here --- then
....
Dim sqlDA As SqlDataAdapter = New SqlDataAdapter("Select *
From tbl2", conn)
sqlDA.UpdateCommand = New SqlCommand("Update tbl2 Set fld1
= @prm1, Set fld2 = @prm2 Where (ID = " & intID & " And
fld1 = '" & str1 & "' fld2 = '" & str2 & "')", conn)
sqlDA.UpdateCommand.CommandType = CommandType.Text
Try
conn.Open()
Dim sqlParm As New SqlParameter
sqlParm = sqlDA.UpdateCommand.Parameters.Add(New
SqlParameter("@prm1", SqlDbType.VarChar, 50, "fld1"))
sqlParm = sqlDA.UpdateCommand.Parameters.Add(New
SqlParameter("@prm2", SqlDbType.VarChar, 50, "fld2"))
dr = ds1.Tables("tbl2").Rows(5)
dr(0) = CType(txtID.Text, Integer)
dr(1) = txtfld1.Text)
dr(2) = txtfld2.Text
sqlDA.Update(ds1, "tbl2") <----> errors out here <-----
conn.Close()
Catch...
I am trying to update a detail table that does not have a
unique key (that is the exercise). With the code below I
am getting the error message "Incorrect syntax near
keyword Set" (note: sql code is all on one line). I may
be guilty of tring to use Com ADO syntax. In the Where
clause I am using declared variables instead of parameter
vars. Is that my error? Please could someone correct my
syntax error below?
----------------------------------------------------------
setting intID, str1 and str2 up here --- then
....
Dim sqlDA As SqlDataAdapter = New SqlDataAdapter("Select *
From tbl2", conn)
sqlDA.UpdateCommand = New SqlCommand("Update tbl2 Set fld1
= @prm1, Set fld2 = @prm2 Where (ID = " & intID & " And
fld1 = '" & str1 & "' fld2 = '" & str2 & "')", conn)
sqlDA.UpdateCommand.CommandType = CommandType.Text
Try
conn.Open()
Dim sqlParm As New SqlParameter
sqlParm = sqlDA.UpdateCommand.Parameters.Add(New
SqlParameter("@prm1", SqlDbType.VarChar, 50, "fld1"))
sqlParm = sqlDA.UpdateCommand.Parameters.Add(New
SqlParameter("@prm2", SqlDbType.VarChar, 50, "fld2"))
dr = ds1.Tables("tbl2").Rows(5)
dr(0) = CType(txtID.Text, Integer)
dr(1) = txtfld1.Text)
dr(2) = txtfld2.Text
sqlDA.Update(ds1, "tbl2") <----> errors out here <-----
conn.Close()
Catch...