Wednesday, March 28, 2012

Invalid syntax near nvarchar

Im trying to update and modify data in a grid view in my sql data base. I keep getting this error..What is the solution to this. Sorry, I have no programing experience. All help will be greatly appreciated. thank you
jdslim

Incorrect syntax near 'nvarchar'.

Description:Anunhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about theerror and where it originated in the code.

Exception Details:System.Data.SqlClient.SqlException: Incorrect syntax near 'nvarchar'.

Source Error:

An unhandled exception was generated during the execution of thecurrent web request. Information regarding the origin and location ofthe exception can be identified using the exception stack trace below.


Stack Trace:

[SqlException (0x80131904): Incorrect syntax near 'nvarchar'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +95
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +82
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +346
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +3244
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +186
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1121
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +334
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +407
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +149
System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +493
System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +915
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +179
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +1140
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +835
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +162
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +56
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +118
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +56
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +107
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +175
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +244
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3840

It would help if you posted your code.

|||

Here is the new stack trace and the code that goes with it. I started a new page that just contains the gridview and the sql data source.

Stack Trace:

[SqlException (0x80131904): Incorrect syntax near 'nvarchar'.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +177 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +68 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +199 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2300 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +147 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1021 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +314 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +413 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +115 System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +392 System.Web.UI.WebControls.SqlDataSourceView.ExecuteDelete(IDictionary keys, IDictionary oldValues) +638 System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) +71 System.Web.UI.WebControls.GridView.HandleDelete(GridViewRow row, Int32 rowIndex) +933 System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +1152 System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +191 System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +172 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4919

<%

@.PageLanguage="VB" %>

<!

DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

scriptrunat="server">

</

script>

<

htmlxmlns="http://www.w3.org/1999/xhtml">

<

headrunat="server"><title>Untitled Page</title>

</

head>

<

body><formid="form1"runat="server"><div> <asp:SqlDataSourceID="SqlDataSource1"runat="server"ConflictDetection="CompareAllValues"ConnectionString="<%$ ConnectionStrings:ConnectionString %>"DeleteCommand="DELETE FROM [Trials] WHERE [Trial#] = @.original_column1 AND [Wet Date] = @.original_Wet_Date AND [Check Date] = @.original_Check_Date AND [Comments] = @.original_Comments"InsertCommand="INSERT INTO [Trials] ([Trial#], [Wet Date], [Check Date], [Comments]) VALUES (@.column1, @.Wet_Date, @.Check_Date, @.Comments)"OldValuesParameterFormatString="original_{0}"SelectCommand="SELECT * FROM [Trials]"UpdateCommand="UPDATE [Trials] SET [Wet Date] = @.Wet_Date, [Check Date] = @.Check_Date, [Comments] = @.Comments WHERE [Trial#] = @.original_column1 AND [Wet Date] = @.original_Wet_Date AND [Check Date] = @.original_Check_Date AND [Comments] = @.original_Comments"><DeleteParameters><asp:ParameterName="original_column1"Type="String"/><asp:ParameterName="original_Wet_Date"Type="DateTime"/><asp:ParameterName="original_Check_Date"Type="DateTime"/><asp:ParameterName="original_Comments"Type="String"/></DeleteParameters><UpdateParameters><asp:ParameterName="Wet_Date"Type="DateTime"/><asp:ParameterName="Check_Date"Type="DateTime"/><asp:ParameterName="Comments"Type="String"/><asp:ParameterName="original_column1"Type="String"/><asp:ParameterName="original_Wet_Date"Type="DateTime"/><asp:ParameterName="original_Check_Date"Type="DateTime"/><asp:ParameterName="original_Comments"Type="String"/></UpdateParameters><InsertParameters><asp:ParameterName="column1"Type="String"/><asp:ParameterName="Wet_Date"Type="DateTime"/><asp:ParameterName="Check_Date"Type="DateTime"/><asp:ParameterName="Comments"Type="String"/></InsertParameters></asp:SqlDataSource></div><asp:GridViewID="GridView1"runat="server"AllowSorting="True"AutoGenerateColumns="False"DataKeyNames="Trial#"DataSourceID="SqlDataSource1"Style="z-index: 100; left: 538px; position: absolute; top: 391px"><Columns><asp:CommandFieldShowDeleteButton="True"ShowEditButton="True"/><asp:BoundFieldDataField="Trial#"HeaderText="Trial#"ReadOnly="True"SortExpression="Trial#"/><asp:BoundFieldDataField="Wet Date"HeaderText="Wet Date"SortExpression="Wet Date"/><asp:BoundFieldDataField="Check Date"HeaderText="Check Date"SortExpression="Check Date"/><asp:BoundFieldDataField="Comments"HeaderText="Comments"SortExpression="Comments"/></Columns></asp:GridView></form>

</

body>

</

html>|||

Hi

I just want to check if you ever solved the problem? I'm sitting with the same thing, but nothing will work...

I've tried the suggestions made, but it still doesn't work.

|||

Hi

I just want to check if you ever solved the problem? I'm sitting with the same thing, but nothing will work...

I've tried the suggestions made, but it still doesn't work.

|||you are better off starting a new thread and post your codes there

No comments:

Post a Comment