Showing posts with label unhandled. Show all posts
Showing posts with label unhandled. Show all posts

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.

Friday, March 23, 2012

Error on SQL .mdf update and edit - nText?

Hello anyone know how to fix this error?

The data types ntext and nvarchar are incompatible in the equal to operator.

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: The data types ntext and nvarchar are incompatible in the equal to operator.

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.

Thanks , John

An nText field can not be used in optimisitic updates. Your update statement that was generated looks something like:

UPDATE SomeTable
SET {Stuff}
WHERE nTextField=old_nTextField

And old_nTextField is defined as a nvarchar. You can't really define it as nText as nText is just a very long nvarchar field, and even if you COULD get it defined as a nText, it would still be invalid, because you can't use nText= anything, even another nText in a WHERE clause.

|||What should it be? I am now using a text , but it still does not work.|||

TEXT/NTEXT/IMAGE data in SQL Server are considered as BLOB (Binary Large Object) data and can not be used with "=" or in sorting. You may need "Text and Image Functions" to manipulate these kinds of data:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_fa-fz_0gs3.asp

Or you can convert the TEXT data (less than 8000 chars) into VARCHAR data to use it in comparation, for example:

select * from test_txt where convert(varchar(8000),t)='The index position of the value parameter if that string is found, or -1 if it is not. If value is Empty, the return value is 0.'

Or use LIKE operator:

select * from test_txt where t like 'The index position of the value parameter if that string is found, or -1 if it is not. If value is Empty, the return value is 0.'

Friday, March 9, 2012

Error Msg

String or binary data would be truncated.
The statement has been terminated.

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: String or binary data would be truncated.
The statement has been terminated.

Source Error:

Line 32: Line 33: Dim add As New SqlCommand(change, conn2)Line 34: add.ExecuteNonQuery()Line 35: conn2.Close()Line 36: Response.Redirect("ThankUReg.aspx")

hi there,

I have this error msg when i try to execute my register page..

What do they mean by string or binary data will be truncated? i've set my database value type to varchar(MAX).

still this error appears.. Looking forward for ur reply.

Yini

well it Does in fact mean that you are trying to insert data into a column that is not big enough for the data. Without knowing your db structure or seeing the SQL your actually using to insert i can't offer much more help. debug the process and maybe copy and paste your values into excel or something so you can run a LEN Function on them and see which one is too big.

hth,
mcm

|||

yinibabe:

i've set my database value type to varchar(MAX).

Have you set the data type to be varchar (max) for every string type column ? My advice is to again check all the columns for their data types, I think you are missing one column which may not allow the amount of data you are trying to insert for that column.

Hope this will help.