Reputation: 125
I have ShowGrid()
, RowEditing
and RowCancelingEdit
but they are correct.
When executing the website I get this general error that I can not figure out:
Incorrect syntax near '('.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '('.
Protected Sub GridView1_OnRowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) Handles GridView1.RowUpdating
Dim connStr, cmdStr As String
connStr = "XXXXX"
cmdStr = "UPDATE OrbitDates SET (JD=@JD,Xecl1=@Xecl1,Yecl1=@Yecl1,Zecl1=@Zecl1) WHERE ido=@ido;"
Try
Using conn As New SqlConnection(connStr)
Using cmd As New SqlCommand(cmdStr, conn)
conn.Open()
cmd.Parameters.AddWithValue("@ido", GridView1.Rows(e.RowIndex).Cells(0).Text)
cmd.Parameters.AddWithValue("@JD", GridView1.Rows(e.RowIndex).Cells(1).Text)
cmd.Parameters.AddWithValue("@Xecl1", GridView1.Rows(e.RowIndex).Cells(2).Text)
cmd.Parameters.AddWithValue("@Yecl1", GridView1.Rows(e.RowIndex).Cells(3).Text)
cmd.Parameters.AddWithValue("@Zecl1", GridView1.Rows(e.RowIndex).Cells(4).Text)
cmd.ExecuteNonQuery()
conn.Close()
cmd.Dispose()
conn.Dispose()
End Using
End Using
Catch ex As Exception
Throw ex
End Try
ViewState("edit") = e.RowIndex
ShowGrid()
End Sub
Upvotes: 1
Views: 2459
Reputation: 149000
Do not use parentheses in your UPDATE statement:
cmdStr = "UPDATE OrbitDates SET JD=@JD,Xecl1=@Xecl1,Yecl1=@Yecl1,Zecl1=@Zecl1 WHERE ido=@ido;"
Upvotes: 4