Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Express Edition and Compact Edition (2005)
 Incorrect syntax near 'nvarchar'

Author  Topic 

abnewallo
Starting Member

6 Posts

Posted - 2006-05-28 : 18:00:22
Can someone help me troubleshoot the following error. It was generated during the update procedure in a Web Developer Express application:

Server Error in '/XprtDr' Application.
--------------------------------------------------------------------------------

Incorrect syntax near 'nvarchar'.
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 'nvarchar'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the 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) +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.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +643
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +78
System.Web.UI.WebControls.FormView.HandleUpdate(String commandArg, Boolean causesValidation) +1151
System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +450
System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs e) +88
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e) +109
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +86
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +156
System.Web.UI.WebControls.LinkButton.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




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-05-28 : 22:14:55
post the update procedure

--------------------
keeping it simple...
Go to Top of Page

abnewallo
Starting Member

6 Posts

Posted - 2006-05-29 : 07:45:20
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [companyDetails_collated]" ConflictDetection="CompareAllValues" DeleteCommand="DELETE FROM [companyDetails_collated] WHERE [indexNo] = @original_indexNo AND [Title] = @original_Title AND [yearEst] = @original_yearEst AND [employeeCount] = @original_employeeCount AND [Address_1] = @original_Address_1 AND [Address_2] = @original_Address_2 AND [Contacts] = @original_Contacts AND [TelNos] = @original_TelNos AND [FaxNos] = @original_FaxNos AND [emailAddresses] = @original_emailAddresses AND [Website] = @original_Website AND [Categories] = @original_Categories AND [Sub_Categories] = @original_Sub_Categories AND [Services] = @original_Services AND [exportMarkets] = @original_exportMarkets AND [Imports] = @original_Imports AND [importSources] = @original_importSources" InsertCommand="INSERT INTO [companyDetails_collated] ([Title], [yearEst], [employeeCount], [Address_1], [Address_2], [Contacts], [TelNos], [FaxNos], [emailAddresses], [Website], [Categories], [Sub_Categories], [Services], [exportMarkets], [Imports], [importSources]) VALUES (@Title, @yearEst, @employeeCount, @Address_1, @Address_2, @Contacts, @TelNos, @FaxNos, @emailAddresses, @Website, @Categories, @Sub_Categories, @Services, @exportMarkets, @Imports, @importSources)" UpdateCommand="UPDATE [companyDetails_collated] SET [Title] = @Title, [yearEst] = @yearEst, [employeeCount] = @employeeCount, [Address_1] = @Address_1, [Address_2] = @Address_2, [Contacts] = @Contacts, [TelNos] = @TelNos, [FaxNos] = @FaxNos, [emailAddresses] = @emailAddresses, [Website] = @Website, [Categories] = @Categories, [Sub_Categories] = @Sub_Categories, [Services] = @Services, [exportMarkets] = @exportMarkets, [Imports] = @Imports, [importSources] = @importSources WHERE [indexNo] = @original_indexNo AND [Title] = @original_Title AND [yearEst] = @original_yearEst AND [employeeCount] = @original_employeeCount AND [Address_1] = @original_Address_1 AND [Address_2] = @original_Address_2 AND [Contacts] = @original_Contacts AND [TelNos] = @original_TelNos AND [FaxNos] = @original_FaxNos AND [emailAddresses] = @original_emailAddresses AND [Website] = @original_Website AND [Categories] = @original_Categories AND [Sub_Categories] = @original_Sub_Categories AND [Services] = @original_Services AND [exportMarkets] = @original_exportMarkets AND [Imports] = @original_Imports AND [importSources] = @original_importSources">
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-05-29 : 22:29:49
in dynamic sql, you need to convert the variables into values, else sql will ask you to declare those variables within the dsql statement

select * from tablename where rowid=@rowid

run in query analyzer, requires declaration of @rowid
so if you run it as dsql, @rowid should be replaced by the value or you need to declare it...

selectstring="select * from tablename where rowid=" & rowid_variable

or best practice is to create the sprocs and just call the sprocs in your apps

--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -