从Gridview更新时出现ASP.NET错误

问题描述:

有人请帮助我解决这个简单的错误,我一直在努力过去几个小时? 我在刚烧笔记本点....从Gridview更新时出现ASP.NET错误

错误: [SQLEXCEPTION(0x80131904):不正确的语法关键字 '集团' 附近]

代码:

Protected Sub GridView1_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) 
    Dim ID As Label = TryCast(GridView1.Rows(e.RowIndex).FindControl("lbl_ID"), Label) 
    Dim AID As TextBox = TryCast(GridView1.Rows(e.RowIndex).FindControl("txt_AID"), TextBox) 
    Dim ADesc As TextBox = TryCast(GridView1.Rows(e.RowIndex).FindControl("txt_ADesc"), TextBox) 
    Dim Status As TextBox = TryCast(GridView1.Rows(e.RowIndex).FindControl("txt_Status"), TextBox) 
    Dim ADate As TextBox = TryCast(GridView1.Rows(e.RowIndex).FindControl("txt_ADate"), TextBox) 
    Dim Category As TextBox = TryCast(GridView1.Rows(e.RowIndex).FindControl("txt_Category"), TextBox) 
    Dim Location As TextBox = TryCast(GridView1.Rows(e.RowIndex).FindControl("txt_Location"), TextBox) 
    Dim CCenter As TextBox = TryCast(GridView1.Rows(e.RowIndex).FindControl("txt_CCenter"), TextBox) 
    Dim Group As TextBox = TryCast(GridView1.Rows(e.RowIndex).FindControl("txt_Group"), TextBox) 
    Dim Life As TextBox = TryCast(GridView1.Rows(e.RowIndex).FindControl("txt_Life"), TextBox) 
    Dim BValue As TextBox = TryCast(GridView1.Rows(e.RowIndex).FindControl("txt_BValue"), TextBox) 
    Dim RRate As TextBox = TryCast(GridView1.Rows(e.RowIndex).FindControl("txt_RRate"), TextBox) 
    Dim RType As TextBox = TryCast(GridView1.Rows(e.RowIndex).FindControl("txt_RType"), TextBox) 
    con = New SqlConnection(cs) 
    con.Open() 

    Dim sqlString As String = "UPDATE Asset_Registry SET [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected] WHERE [email protected]" 
    Dim cmd As New SqlCommand(sqlString, con) 
    cmd.Parameters.AddWithValue("@AID", AID.Text) 
    cmd.Parameters.AddWithValue("@ADesc", ADesc.Text) 
    cmd.Parameters.AddWithValue("@Status", Status.Text) 
    cmd.Parameters.AddWithValue("@ADate", ADate.Text) 
    cmd.Parameters.AddWithValue("@Category", Category.Text) 
    cmd.Parameters.AddWithValue("@Location", Location.Text) 
    cmd.Parameters.AddWithValue("@CCenter", CCenter.Text) 
    cmd.Parameters.AddWithValue("@Group", Group.Text) 
    cmd.Parameters.AddWithValue("@Life", Life.Text) 
    cmd.Parameters.AddWithValue("@BValue", BValue.Text) 
    cmd.Parameters.AddWithValue("@RRate", RRate.Text) 
    cmd.Parameters.AddWithValue("@RType", RType.Text) 

    cmd.ExecuteNonQuery() 
    con.Close() 
    GridView1.EditIndex = -1 
    ShowData() 
End Sub 
+2

保留字,划呀! – jarlh

+0

打印查询和检查。什么不见​​了? –

GROUP是SQL Server中的reserved word,与[]逃避它:

UPDATE Asset_Registry 
SET [email protected], 
    [email protected], 
    ... 
    [Group][email protected] -- <----- 
    ... 
WHERE [email protected]