I am getting the following error when I try to update a record in a datagrid. I am new to ASP.NET and this is a tutorial I am going through. I have never seen the error before so I don't know how to trouble shoot it.
Incorrect syntax near 'Stevens'.
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: Line 1: Incorrect syntax near 'Stevens'.
Source Error:
Line 46: myCommand = new SqlCommand(strUpdateStmt, myConnection)
Line 47: myConnection.open()
Line 48: myCommand.ExecuteNonQuery()
Line 49:
Line 50: personInfo.EditItemIndex = -1
Source File: E:\Intranet\Mystuff\aspnet\tryaspnet.aspx Line: 48
Stack Trace:
[SqlException: Line 1: Incorrect syntax near 'Stevens'.]
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +192
ASP.tryaspnet_aspx.DataGrid_Update(Object Source, DataGridCommandEventArgs E) in E:\Intranet\Mystuff\aspnet\tryaspnet.aspx:48
System.Web.UI.WebControls.DataGrid.OnUpdateCommand(DataGridCommandEventArgs e) +109
System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source, EventArgs e) +748
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source, EventArgs e) +106
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +121
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +115
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +138
System.Web.UI.Page.ProcessRequestMain() +1263
Incorrect syntax near 'Stevens'.
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: Line 1: Incorrect syntax near 'Stevens'.
Source Error:
Line 46: myCommand = new SqlCommand(strUpdateStmt, myConnection)
Line 47: myConnection.open()
Line 48: myCommand.ExecuteNonQuery()
Line 49:
Line 50: personInfo.EditItemIndex = -1
Source File: E:\Intranet\Mystuff\aspnet\tryaspnet.aspx Line: 48
Stack Trace:
[SqlException: Line 1: Incorrect syntax near 'Stevens'.]
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +192
ASP.tryaspnet_aspx.DataGrid_Update(Object Source, DataGridCommandEventArgs E) in E:\Intranet\Mystuff\aspnet\tryaspnet.aspx:48
System.Web.UI.WebControls.DataGrid.OnUpdateCommand(DataGridCommandEventArgs e) +109
System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source, EventArgs e) +748
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source, EventArgs e) +106
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +121
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +115
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +138
System.Web.UI.Page.ProcessRequestMain() +1263