S
Solidus
I have a ASP.net form on a Sharepoint Site that connects to a SQL 2000
database. When I try to update or insert a record I get the following error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Line 1: 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: Line 1: 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): Line 1: Incorrect syntax near 'nvarchar'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection) +786226
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) +684838
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj) +207
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand
cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
bulkCopyHandler, TdsParserStateObject stateObj) +1751
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,
RunBehavior runBehavior, String resetOptionsString) +107
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
+570
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method,
DbAsyncResult result) +134
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) +405
System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +718
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values,
IDictionary oldValues, DataSourceViewOperationCallback callback) +78
System.Web.UI.WebControls.DetailsView.HandleUpdate(String commandArg,
Boolean causesValidation) +1146
System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean
causesValidation, String validationGroup) +643
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) +134
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) +180
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5670
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50215.44; ASP.NET
Version:2.0.50215.44
here is the form code:
<%@ Page Language="VB" %>
<script runat="server">
Protected Sub SqlDataSourceGV_Selecting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs)
End Sub
Protected Sub DetailsView1_PageIndexChanging(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DetailsViewPageEventArgs)
End Sub
</script>
<html>
<head>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div style="background-color:#1e3c7b;Width:541px">
<span style="color: #ffffff"><span style="font-size:
16pt"><strong>P & P Tracking</strong><br />
</span><strong>
Find a Case</strong></span></div><div
style="background-color:#5f7eba;font-size:1;Height:10px;Width:541px"></div>
<div style="background-color:#c1e0ff;Width:541px">
<strong>Case Number </strong><span style="font-size:
10pt">(Enter any part of a case number)<br />
</span><br />
<asp:TextBox ID="textbox" Runat="server" />
<asp:Button ID="Button1" Runat="server" Text="Find" /><br /><br /></div>
<aspetailsView ID="DetailsView1" runat="server"
AutoGenerateRows="False" AutoGenerateDeleteButton=True
AutoGenerateEditButton=True AutoGenerateInsertButton=True DataKeyNames="Case
Number"
DataSourceID="SqlDataSourceGV" Height="60%" Width="541px"
CellPadding="4" ForeColor="#333333" GridLines="None" AllowPaging="True"
OnPageIndexChanging="DetailsView1_PageIndexChanging">
<Fields>
<asp:BoundField DataField="Case Number" HeaderText="Case
Number" ReadOnly="True"
SortExpression="Case Number" />
<asp:BoundField DataField="Street Address" HeaderText="Street
Address" SortExpression="Street Address" />
<asp:BoundField DataField="Zip" HeaderText="Zip"
SortExpression="Zip" />
<asp:BoundField DataField="Request_Type"
HeaderText="Request_Type" SortExpression="Request_Type" />
<asp:BoundField DataField="Mortgagee_Name"
HeaderText="Mortgagee_Name" SortExpression="Mortgagee_Name" />
<asp:BoundField DataField="Approved" HeaderText="Approved"
SortExpression="Approved" />
<asp:BoundField DataField="Comments" HeaderText="Comments"
SortExpression="Comments" />
<asp:BoundField DataField="Date In" HeaderText="Date In"
SortExpression="Date In" />
<asp:BoundField DataField="Date Out" HeaderText="Date Out"
SortExpression="Date Out" />
<asp:CheckBoxField DataField="Conveyed" HeaderText="Conveyed"
SortExpression="Conveyed" />
</Fields>
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<CommandRowStyle BackColor="#D1DDF1" Font-Bold="True"
HorizontalAlign="Left" VerticalAlign="Top" Width="50px" />
<RowStyle BackColor="#EFF3FB" />
<FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True"
HorizontalAlign="Right" Width="100px" />
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</aspetailsView>
<asp:SqlDataSource ID="SqlDataSourceGV"
ConnectionString="Data Source=10.0.0.3;Initial
Catalog=tracker;Persist Security Info=True
SelectCommand="SELECT * FROM [Main Table] WHERE ([Case Number] LIKE
'%' + @Case_Number + '%')"
Runat="server" ProviderName="System.Data.SqlClient"
ConflictDetection="CompareAllValues" DeleteCommand="DELETE FROM [Main Table]
WHERE [Case Number] = @original_Case_Number AND [Street Address] =
@original_Street_Address AND [Zip] = @original_Zip AND [Request_Type] =
@original_Request_Type AND [Mortgagee_Name] = @original_Mortgagee_Name AND
[Approved] = @original_Approved AND [Comments] = @original_Comments AND [Date
In] = @original_Date_In AND [Date Out] = @original_Date_Out AND [Conveyed] =
@original_Conveyed" InsertCommand="INSERT INTO [Main Table] ([Case Number],
[Street Address], [Zip], [Request_Type], [Mortgagee_Name], [Approved],
[Comments], [Date In], [Date Out], [Conveyed]) VALUES (@Case_Number,
@Street_Address, @Zip, @Request_Type, @Mortgagee_Name, @Approved, @Comments,
@Date_In, @Date_Out, @Conveyed)" OnSelecting="SqlDataSourceGV_Selecting"
UpdateCommand="UPDATE [Main Table] SET [Street Address] = @Street_Address,
[Zip] = @Zip, [Request_Type] = @Request_Type, [Mortgagee_Name] =
@Mortgagee_Name, [Approved] = @Approved, [Comments] = @Comments, [Date In] =
@Date_In, [Date Out] = @Date_Out, [Conveyed] = @Conveyed WHERE [Case Number]
= @original_Case_Number AND [Street Address] = @original_Street_Address AND
[Zip] = @original_Zip AND [Request_Type] = @original_Request_Type AND
[Mortgagee_Name] = @original_Mortgagee_Name AND [Approved] =
@original_Approved AND [Comments] = @original_Comments AND [Date In] =
@original_Date_In AND [Date Out] = @original_Date_Out AND [Conveyed] =
@original_Conveyed">
<DeleteParameters>
<asparameter Name="original_Case_Number" Type="String" />
<asparameter Name="original_Street_Address" Type="String" />
<asparameter Name="original_Zip" Type="String" />
<asparameter Name="original_Request_Type" Type="String" />
<asparameter Name="original_Mortgagee_Name" Type="String" />
<asparameter Name="original_Approved" Type="String" />
<asparameter Name="original_Comments" Type="String" />
<asparameter Name="original_Date_In" Type="DateTime" />
<asparameter Name="original_Date_Out" Type="DateTime" />
<asparameter Name="original_Conveyed" Type="Boolean" />
</DeleteParameters>
<UpdateParameters>
<asparameter Name="Street_Address" Type="String" />
<asparameter Name="Zip" Type="String" />
<asparameter Name="Request_Type" Type="String" />
<asparameter Name="Mortgagee_Name" Type="String" />
<asparameter Name="Approved" Type="String" />
<asparameter Name="Comments" Type="String" />
<asparameter Name="Date_In" Type="DateTime" />
<asparameter Name="Date_Out" Type="DateTime" />
<asparameter Name="Conveyed" Type="Boolean" />
<asparameter Name="original_Case_Number" Type="String" />
<asparameter Name="original_Street_Address" Type="String" />
<asparameter Name="original_Zip" Type="String" />
<asparameter Name="original_Request_Type" Type="String" />
<asparameter Name="original_Mortgagee_Name" Type="String" />
<asparameter Name="original_Approved" Type="String" />
<asparameter Name="original_Comments" Type="String" />
<asparameter Name="original_Date_In" Type="DateTime" />
<asparameter Name="original_Date_Out" Type="DateTime" />
<asparameter Name="original_Conveyed" Type="Boolean" />
</UpdateParameters>
<InsertParameters>
<asparameter Name="Case_Number" Type="String" />
<asparameter Name="Street_Address" Type="String" />
<asparameter Name="Zip" Type="String" />
<asparameter Name="Request_Type" Type="String" />
<asparameter Name="Mortgagee_Name" Type="String" />
<asparameter Name="Approved" Type="String" />
<asparameter Name="Comments" Type="String" />
<asparameter Name="Date_In" Type="DateTime" />
<asparameter Name="Date_Out" Type="DateTime" />
<asparameter Name="Conveyed" Type="Boolean" />
</InsertParameters>
<SelectParameters>
<asp:FormParameter FormField="textbox" Name="Case_Number"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</form>
</body>
</html>
Any ideas? Thanks.
database. When I try to update or insert a record I get the following error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Line 1: 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: Line 1: 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): Line 1: Incorrect syntax near 'nvarchar'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection) +786226
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) +684838
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj) +207
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand
cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
bulkCopyHandler, TdsParserStateObject stateObj) +1751
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,
RunBehavior runBehavior, String resetOptionsString) +107
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
+570
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method,
DbAsyncResult result) +134
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) +405
System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +718
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values,
IDictionary oldValues, DataSourceViewOperationCallback callback) +78
System.Web.UI.WebControls.DetailsView.HandleUpdate(String commandArg,
Boolean causesValidation) +1146
System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean
causesValidation, String validationGroup) +643
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) +134
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) +180
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5670
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50215.44; ASP.NET
Version:2.0.50215.44
here is the form code:
<%@ Page Language="VB" %>
<script runat="server">
Protected Sub SqlDataSourceGV_Selecting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs)
End Sub
Protected Sub DetailsView1_PageIndexChanging(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DetailsViewPageEventArgs)
End Sub
</script>
<html>
<head>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div style="background-color:#1e3c7b;Width:541px">
<span style="color: #ffffff"><span style="font-size:
16pt"><strong>P & P Tracking</strong><br />
</span><strong>
Find a Case</strong></span></div><div
style="background-color:#5f7eba;font-size:1;Height:10px;Width:541px"></div>
<div style="background-color:#c1e0ff;Width:541px">
<strong>Case Number </strong><span style="font-size:
10pt">(Enter any part of a case number)<br />
</span><br />
<asp:TextBox ID="textbox" Runat="server" />
<asp:Button ID="Button1" Runat="server" Text="Find" /><br /><br /></div>
<aspetailsView ID="DetailsView1" runat="server"
AutoGenerateRows="False" AutoGenerateDeleteButton=True
AutoGenerateEditButton=True AutoGenerateInsertButton=True DataKeyNames="Case
Number"
DataSourceID="SqlDataSourceGV" Height="60%" Width="541px"
CellPadding="4" ForeColor="#333333" GridLines="None" AllowPaging="True"
OnPageIndexChanging="DetailsView1_PageIndexChanging">
<Fields>
<asp:BoundField DataField="Case Number" HeaderText="Case
Number" ReadOnly="True"
SortExpression="Case Number" />
<asp:BoundField DataField="Street Address" HeaderText="Street
Address" SortExpression="Street Address" />
<asp:BoundField DataField="Zip" HeaderText="Zip"
SortExpression="Zip" />
<asp:BoundField DataField="Request_Type"
HeaderText="Request_Type" SortExpression="Request_Type" />
<asp:BoundField DataField="Mortgagee_Name"
HeaderText="Mortgagee_Name" SortExpression="Mortgagee_Name" />
<asp:BoundField DataField="Approved" HeaderText="Approved"
SortExpression="Approved" />
<asp:BoundField DataField="Comments" HeaderText="Comments"
SortExpression="Comments" />
<asp:BoundField DataField="Date In" HeaderText="Date In"
SortExpression="Date In" />
<asp:BoundField DataField="Date Out" HeaderText="Date Out"
SortExpression="Date Out" />
<asp:CheckBoxField DataField="Conveyed" HeaderText="Conveyed"
SortExpression="Conveyed" />
</Fields>
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<CommandRowStyle BackColor="#D1DDF1" Font-Bold="True"
HorizontalAlign="Left" VerticalAlign="Top" Width="50px" />
<RowStyle BackColor="#EFF3FB" />
<FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True"
HorizontalAlign="Right" Width="100px" />
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</aspetailsView>
<asp:SqlDataSource ID="SqlDataSourceGV"
ConnectionString="Data Source=10.0.0.3;Initial
Catalog=tracker;Persist Security Info=True
SelectCommand="SELECT * FROM [Main Table] WHERE ([Case Number] LIKE
'%' + @Case_Number + '%')"
Runat="server" ProviderName="System.Data.SqlClient"
ConflictDetection="CompareAllValues" DeleteCommand="DELETE FROM [Main Table]
WHERE [Case Number] = @original_Case_Number AND [Street Address] =
@original_Street_Address AND [Zip] = @original_Zip AND [Request_Type] =
@original_Request_Type AND [Mortgagee_Name] = @original_Mortgagee_Name AND
[Approved] = @original_Approved AND [Comments] = @original_Comments AND [Date
In] = @original_Date_In AND [Date Out] = @original_Date_Out AND [Conveyed] =
@original_Conveyed" InsertCommand="INSERT INTO [Main Table] ([Case Number],
[Street Address], [Zip], [Request_Type], [Mortgagee_Name], [Approved],
[Comments], [Date In], [Date Out], [Conveyed]) VALUES (@Case_Number,
@Street_Address, @Zip, @Request_Type, @Mortgagee_Name, @Approved, @Comments,
@Date_In, @Date_Out, @Conveyed)" OnSelecting="SqlDataSourceGV_Selecting"
UpdateCommand="UPDATE [Main Table] SET [Street Address] = @Street_Address,
[Zip] = @Zip, [Request_Type] = @Request_Type, [Mortgagee_Name] =
@Mortgagee_Name, [Approved] = @Approved, [Comments] = @Comments, [Date In] =
@Date_In, [Date Out] = @Date_Out, [Conveyed] = @Conveyed WHERE [Case Number]
= @original_Case_Number AND [Street Address] = @original_Street_Address AND
[Zip] = @original_Zip AND [Request_Type] = @original_Request_Type AND
[Mortgagee_Name] = @original_Mortgagee_Name AND [Approved] =
@original_Approved AND [Comments] = @original_Comments AND [Date In] =
@original_Date_In AND [Date Out] = @original_Date_Out AND [Conveyed] =
@original_Conveyed">
<DeleteParameters>
<asparameter Name="original_Case_Number" Type="String" />
<asparameter Name="original_Street_Address" Type="String" />
<asparameter Name="original_Zip" Type="String" />
<asparameter Name="original_Request_Type" Type="String" />
<asparameter Name="original_Mortgagee_Name" Type="String" />
<asparameter Name="original_Approved" Type="String" />
<asparameter Name="original_Comments" Type="String" />
<asparameter Name="original_Date_In" Type="DateTime" />
<asparameter Name="original_Date_Out" Type="DateTime" />
<asparameter Name="original_Conveyed" Type="Boolean" />
</DeleteParameters>
<UpdateParameters>
<asparameter Name="Street_Address" Type="String" />
<asparameter Name="Zip" Type="String" />
<asparameter Name="Request_Type" Type="String" />
<asparameter Name="Mortgagee_Name" Type="String" />
<asparameter Name="Approved" Type="String" />
<asparameter Name="Comments" Type="String" />
<asparameter Name="Date_In" Type="DateTime" />
<asparameter Name="Date_Out" Type="DateTime" />
<asparameter Name="Conveyed" Type="Boolean" />
<asparameter Name="original_Case_Number" Type="String" />
<asparameter Name="original_Street_Address" Type="String" />
<asparameter Name="original_Zip" Type="String" />
<asparameter Name="original_Request_Type" Type="String" />
<asparameter Name="original_Mortgagee_Name" Type="String" />
<asparameter Name="original_Approved" Type="String" />
<asparameter Name="original_Comments" Type="String" />
<asparameter Name="original_Date_In" Type="DateTime" />
<asparameter Name="original_Date_Out" Type="DateTime" />
<asparameter Name="original_Conveyed" Type="Boolean" />
</UpdateParameters>
<InsertParameters>
<asparameter Name="Case_Number" Type="String" />
<asparameter Name="Street_Address" Type="String" />
<asparameter Name="Zip" Type="String" />
<asparameter Name="Request_Type" Type="String" />
<asparameter Name="Mortgagee_Name" Type="String" />
<asparameter Name="Approved" Type="String" />
<asparameter Name="Comments" Type="String" />
<asparameter Name="Date_In" Type="DateTime" />
<asparameter Name="Date_Out" Type="DateTime" />
<asparameter Name="Conveyed" Type="Boolean" />
</InsertParameters>
<SelectParameters>
<asp:FormParameter FormField="textbox" Name="Case_Number"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</form>
</body>
</html>
Any ideas? Thanks.