G
Guest
When I run the following UpdateCommand event I get the error: "Line 1:
Incorrect syntax near '?'." and the highlighted line is
"updateCommand.ExecuteNonQuery()". I've been troubleshooting this for 2
hours and have no clue what the problem is. Could someone please help me
understand what is going wrong? Thanks.
Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
DataGrid1.UpdateCommand
'Retrieve the values from the control
Dim PKColumn As String
PKColumn = (CType(e.Item.FindControl("HL99"), HyperLink)).Text
Dim SpecieID As Integer
SpecieID = Integer.Parse(CType(e.Item.Cells(3).Controls(1),
DropDownList).SelectedItem.Value)
Dim updateCommand As New SqlCommand("UPDATE tblLogs SET SpecieID = ?
WHERE (PKColumn = ?)", SqlConnection1)
updateCommand.Parameters.Add("@SpecieID", SqlDbType.VarChar).Value
= SpecieID
updateCommand.Parameters.Add("@PKColumn", SqlDbType.VarChar).Value =
PKColumn
updateCommand.Connection.Open()
updateCommand.ExecuteNonQuery()
'Routine tasks...
DataGrid1.EditItemIndex = -1
Bind()
End Sub
Incorrect syntax near '?'." and the highlighted line is
"updateCommand.ExecuteNonQuery()". I've been troubleshooting this for 2
hours and have no clue what the problem is. Could someone please help me
understand what is going wrong? Thanks.
Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
DataGrid1.UpdateCommand
'Retrieve the values from the control
Dim PKColumn As String
PKColumn = (CType(e.Item.FindControl("HL99"), HyperLink)).Text
Dim SpecieID As Integer
SpecieID = Integer.Parse(CType(e.Item.Cells(3).Controls(1),
DropDownList).SelectedItem.Value)
Dim updateCommand As New SqlCommand("UPDATE tblLogs SET SpecieID = ?
WHERE (PKColumn = ?)", SqlConnection1)
updateCommand.Parameters.Add("@SpecieID", SqlDbType.VarChar).Value
= SpecieID
updateCommand.Parameters.Add("@PKColumn", SqlDbType.VarChar).Value =
PKColumn
updateCommand.Connection.Open()
updateCommand.ExecuteNonQuery()
'Routine tasks...
DataGrid1.EditItemIndex = -1
Bind()
End Sub