Monday, March 26, 2012

error please help

any Idea why i am getting this error?

Server Error in '/endorse' 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) +890426 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +767130 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1956 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +149 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +903 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +415 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135 System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +404 System.Web.UI.WebControls.SqlDataSourceView.ExecuteInsert(IDictionary values) +447 System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) +72 System.Web.UI.WebControls.DetailsView.HandleInsert(String commandArg, Boolean causesValidation) +390 System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +623 System.Web.UI.WebControls.DetailsView.OnBubbleEvent(Object source, EventArgs e) +95 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35 System.Web.UI.WebControls.DetailsViewRow.OnBubbleEvent(Object source, EventArgs e) +109 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35 System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115 System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +163 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) +174 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5104



Version Information: Microsoft .NET Framework Version:2.0.50727.1318; ASP.NET Version:2.0.50727.1318

My code is like........

<%@.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:LoginViewID="LoginView1"runat="server">

<LoggedInTemplate>

<asp:DetailsViewID="DetailsView1"runat="server"AllowPaging="True"AutoGenerateRows="False"

DataKeyNames="id"DataSourceID="SqlDataSource1"Height="50px"Width="125px">

<Fields>

<asp:BoundFieldDataField="RoomNo"HeaderText="RoomNo"SortExpression="RoomNo"/>

<asp:BoundFieldDataField="Name MR"HeaderText="Name MR"SortExpression="Name MR"/>

<asp:BoundFieldDataField="Att Resi"HeaderText="Att Resi"SortExpression="Att Resi"/>

<asp:BoundFieldDataField="Age Sex"HeaderText="Age Sex"SortExpression="Age Sex"/>

<asp:BoundFieldDataField="Adm Date"HeaderText="Adm Date"SortExpression="Adm Date"/>

<asp:BoundFieldDataField="Diagnosis"HeaderText="Diagnosis"SortExpression="Diagnosis"/>

<asp:BoundFieldDataField="Diet IVF"HeaderText="Diet IVF"SortExpression="Diet IVF"/>

<asp:BoundFieldDataField="Medications"HeaderText="Medications"SortExpression="Medications"/>

<asp:BoundFieldDataField="Consults"HeaderText="Consults"SortExpression="Consults"/>

<asp:BoundFieldDataField="Followup"HeaderText="Followup"SortExpression="Followup"/>

<asp:CommandFieldShowDeleteButton="True"ShowEditButton="True"ShowInsertButton="True"/>

</Fields>

</asp:DetailsView>

<asp:SqlDataSourceID="SqlDataSource1"runat="server"ConflictDetection="CompareAllValues"

ConnectionString="<%$ ConnectionStrings:endorseConnectionString1 %>"DeleteCommand="DELETE FROM [endorse] WHERE [id] = @.original_id AND [RoomNo] = @.original_RoomNo AND [Name MR] = @.original_Name_MR AND [Att Resi] = @.original_Att_Resi AND [Age Sex] = @.original_Age_Sex AND [Adm Date] = @.original_Adm_Date AND [Diagnosis] = @.original_Diagnosis AND [Diet IVF] = @.original_Diet_IVF AND [Medications] = @.original_Medications AND [Consults] = @.original_Consults AND [Followup] = @.original_Followup"

InsertCommand="INSERT INTO [endorse] ([RoomNo], [Name MR], [Att Resi], [Age Sex], [Adm Date], [Diagnosis], [Diet IVF], [Medications], [Consults], [Followup]) VALUES (@.RoomNo, @.Name_MR, @.Att_Resi, @.Age_Sex, @.Adm_Date, @.Diagnosis, @.Diet_IVF, @.Medications, @.Consults, @.Followup)"

OldValuesParameterFormatString="original_{0}"SelectCommand="SELECT * FROM [endorse] WHERE ([id] = @.id)"

UpdateCommand="UPDATE [endorse] SET [RoomNo] = @.RoomNo, [Name MR] = @.Name_MR, [Att Resi] = @.Att_Resi, [Age Sex] = @.Age_Sex, [Adm Date] = @.Adm_Date, [Diagnosis] = @.Diagnosis, [Diet IVF] = @.Diet_IVF, [Medications] = @.Medications, [Consults] = @.Consults, [Followup] = @.Followup WHERE [id] = @.original_id AND [RoomNo] = @.original_RoomNo AND [Name MR] = @.original_Name_MR AND [Att Resi] = @.original_Att_Resi AND [Age Sex] = @.original_Age_Sex AND [Adm Date] = @.original_Adm_Date AND [Diagnosis] = @.original_Diagnosis AND [Diet IVF] = @.original_Diet_IVF AND [Medications] = @.original_Medications AND [Consults] = @.original_Consults AND [Followup] = @.original_Followup">

<SelectParameters>

<asp:QueryStringParameterDefaultValue="0"Name="id"QueryStringField="id"Type="Int32"/>

</SelectParameters>

<DeleteParameters>

<asp:ParameterName="original_id"Type="Int32"/>

<asp:ParameterName="original_RoomNo"Type="Int32"/>

<asp:ParameterName="original_Name_MR"Type="String"/>

<asp:ParameterName="original_Att_Resi"Type="String"/>

<asp:ParameterName="original_Age_Sex"Type="String"/>

<asp:ParameterName="original_Adm_Date"Type="DateTime"/>

<asp:ParameterName="original_Diagnosis"Type="String"/>

<asp:ParameterName="original_Diet_IVF"Type="String"/>

<asp:ParameterName="original_Medications"Type="String"/>

<asp:ParameterName="original_Consults"Type="String"/>

<asp:ParameterName="original_Followup"Type="String"/>

</DeleteParameters>

<UpdateParameters>

<asp:ParameterName="RoomNo"Type="Int32"/>

<asp:ParameterName="Name_MR"Type="String"/>

<asp:ParameterName="Att_Resi"Type="String"/>

<asp:ParameterName="Age_Sex"Type="String"/>

<asp:ParameterName="Adm_Date"Type="DateTime"/>

<asp:ParameterName="Diagnosis"Type="String"/>

<asp:ParameterName="Diet_IVF"Type="String"/>

<asp:ParameterName="Medications"Type="String"/>

<asp:ParameterName="Consults"Type="String"/>

<asp:ParameterName="Followup"Type="String"/>

<asp:ParameterName="original_id"Type="Int32"/>

<asp:ParameterName="original_RoomNo"Type="Int32"/>

<asp:ParameterName="original_Name_MR"Type="String"/>

<asp:ParameterName="original_Att_Resi"Type="String"/>

<asp:ParameterName="original_Age_Sex"Type="String"/>

<asp:ParameterName="original_Adm_Date"Type="DateTime"/>

<asp:ParameterName="original_Diagnosis"Type="String"/>

<asp:ParameterName="original_Diet_IVF"Type="String"/>

<asp:ParameterName="original_Medications"Type="String"/>

<asp:ParameterName="original_Consults"Type="String"/>

<asp:ParameterName="original_Followup"Type="String"/>

</UpdateParameters>

<InsertParameters>

<asp:ParameterName="RoomNo"Type="Int32"/>

<asp:ParameterName="Name_MR"Type="String"/>

<asp:ParameterName="Att_Resi"Type="String"/>

<asp:ParameterName="Age_Sex"Type="String"/>

<asp:ParameterName="Adm_Date"Type="DateTime"/>

<asp:ParameterName="Diagnosis"Type="String"/>

<asp:ParameterName="Diet_IVF"Type="String"/>

<asp:ParameterName="Medications"Type="String"/>

<asp:ParameterName="Consults"Type="String"/>

<asp:ParameterName="Followup"Type="String"/>

</InsertParameters>

</asp:SqlDataSource>

</LoggedInTemplate>

<AnonymousTemplate>

you are not logged in.

</AnonymousTemplate>

</asp:LoginView>

</div>

</form>

</body>

</html>

Here is a wild shot in the dark...

I notice there is a field called Age_Sex. Is it possible the data being inserted has a comma between the two data items?

Even if it isn't causing the problem, having two data items in one field certainly will raise some eyebrows, if not some havoc.

|||

Thanks for your reply steve,

I tried to remove the comma from the data fields and still the same error. I don't want to many columns in the table thats why i am combining the fields, I know database design is not efficient in that way but it is surving the purpose for me.

If you could help further I will appriciate it.

Thanks again.

No comments:

Post a Comment