Hey guys,
Am new at using ASP.Net. am having some problems updating my SQL DB. whenever i try i get this Error. Can someone help me?
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(SqlExc eption exception, Boolean breakConnection) +177
System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection) +68
System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj) +199
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2305
System.Data.SqlClient.SqlCommand.FinishExecuteRead er(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +147
System.Data.SqlClient.SqlCommand.RunExecuteReaderT ds(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.InternalExecuteNo nQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +413
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +115
System.Web.UI.WebControls.SqlDataSourceView.Execut eDbCommand(DbCommand command, DataSourceOperation operation) +392
System.Web.UI.WebControls.SqlDataSourceView.Execut eUpdate(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(St ring commandArg, Boolean causesValidation) +1151
System.Web.UI.WebControls.FormView.HandleEvent(Eve ntArgs e, Boolean causesValidation, String validationGroup) +450
System.Web.UI.WebControls.FormView.OnBubbleEvent(O bject source, EventArgs e) +88
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.FormViewRow.OnBubbleEven t(Object source, EventArgs e) +109
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(Com mandEventArgs e) +86
System.Web.UI.WebControls.LinkButton.RaisePostBack Event(String eventArgument) +156
System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +172
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4921
Here is my code
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="LostAndFound.aspx.vb" Inherits="Default2" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table>
<tr>
<td style="width: 312px; height: 5px">
</td>
<td style="width: 100px; height: 5px">
</td>
<td style="width: 100px; height: 5px">
</td>
<td style="width: 100px; height: 5px">
</td>
</tr>
<tr>
<td style="width: 312px; height: 25px">
</td>
<td colspan="2" style="height: 25px; text-align: center">
<strong><span style="font-size: 16pt; color: olive; font-family: Verdana">Lost and Found</span></strong></td>
<td style="width: 100px; height: 25px">
</td>
</tr>
<tr>
<td style="width: 312px; height: 257px">
</td>
<td colspan="2" style="height: 257px; vertical-align: top; text-align: left;">
<asp:FormView ID="FormView1" runat="server" CellPadding="4" DataKeyNames="Item ID"
DataSourceID="SqlDataSource1" ForeColor="#333333">
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<EditItemTemplate>
<table>
<tr>
<td style="width: 156px">
Item ID:
</td>
<td style="width: 100px">
<asp:Label ID="Item_IDLabel1" runat="server" Text='<%# Eval("[Item ID]") %>'></asp:Label></td>
</tr>
<tr>
<td style="width: 156px">
Date:</td>
<td style="width: 100px">
<asp:TextBox ID="DateTextBox" runat="server" Text='<%# Bind("Date") %>'></asp:TextBox></td>
</tr>
<tr>
<td style="width: 156px">
Book Title:</td>
<td style="width: 100px">
<asp:TextBox ID="Book_TitleTextBox" runat="server" Text='<%# Bind("[Book Title]") %>'></asp:TextBox></td>
</tr>
<tr>
<td style="width: 156px">
Book Number:
</td>
<td style="width: 100px">
<asp:TextBox ID="Book_NumberTextBox" runat="server" Text='<%# Bind("[Book Number]") %>'></asp:TextBox></td>
</tr>
<tr>
<td style="width: 156px">
Student Name:
</td>
<td style="width: 100px">
<asp:TextBox ID="Student_NameTextBox" runat="server" Text='<%# Bind("[Student Name]") %>'></asp:TextBox></td>
</tr>
<tr>
<td style="width: 156px">
Grade:
</td>
<td style="width: 100px">
<asp:TextBox ID="GradeTextBox" runat="server" Text='<%# Bind("Grade") %>'></asp:TextBox></td>
</tr>
<tr>
<td style="width: 156px">
Date Recieved:
</td>
<td style="width: 100px">
<asp:TextBox ID="Date_RecievedTextBox" runat="server" Text='<%# Bind("[Date Recieved]") %>'></asp:TextBox></td>
</tr>
<tr>
<td colspan="2">
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="Update"></asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel"></asp:LinkButton></td>
</tr>
</table>
</EditItemTemplate>
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<InsertItemTemplate>
<table>
<tr>
<td style="width: 153px">
Date:
</td>
<td style="width: 100px">
<asp:TextBox ID="DateTextBox" runat="server" Text='<%# Bind("Date") %>'></asp:TextBox></td>
</tr>
<tr>
<td style="width: 153px">
Book Title:</td>
<td style="width: 100px">
<asp:TextBox ID="Book_TitleTextBox" runat="server" Text='<%# Bind("[Book Title]") %>'></asp:TextBox></td>
</tr>
<tr>
<td style="width: 153px">
Book Number:</td>
<td style="width: 100px">
<asp:TextBox ID="Book_NumberTextBox" runat="server" Text='<%# Bind("[Book Number]") %>'></asp:TextBox></td>
</tr>
<tr>
<td style="width: 153px">
Student Name:
</td>
<td style="width: 100px">
<asp:TextBox ID="Student_NameTextBox" runat="server" Text='<%# Bind("[Student Name]") %>'></asp:TextBox></td>
</tr>
<tr>
<td style="width: 153px">
Grade:</td>
<td style="width: 100px">
<asp:TextBox ID="GradeTextBox" runat="server" Text='<%# Bind("Grade") %>'></asp:TextBox></td>
</tr>
<tr>
<td style="width: 153px">
Date Recieved:</td>
<td style="width: 100px">
<asp:TextBox ID="Date_RecievedTextBox" runat="server" Text='<%# Bind("[Date Recieved]") %>'></asp:TextBox></td>
</tr>
<tr>
<td colspan="2">
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
Text="Insert"></asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel"></asp:LinkButton></td>
</tr>
</table>
</InsertItemTemplate>
<ItemTemplate>
<table>
<tr>
<td style="width: 138px">
Item ID:
</td>
<td style="width: 108px">
<asp:Label ID="Item_IDLabel" runat="server" Text='<%# Eval("[Item ID]") %>'></asp:Label></td>
</tr>
<tr>
<td style="width: 138px">
Date:
</td>
<td style="width: 108px">
<asp:Label ID="DateLabel" runat="server" Text='<%# Bind("Date") %>'></asp:Label></td>
</tr>
<tr>
<td style="width: 138px">
Book Title:</td>
<td style="width: 108px">
<asp:Label ID="Book_TitleLabel" runat="server" Text='<%# Bind("[Book Title]") %>'
Width="175px"></asp:Label></td>
</tr>
<tr>
<td style="width: 138px">
Book Number:
</td>
<td style="width: 108px">
<asp:Label ID="Book_NumberLabel" runat="server" Text='<%# Bind("[Book Number]") %>'></asp:Label></td>
</tr>
<tr>
<td style="width: 138px">
Student Name:
</td>
<td style="width: 108px">
<asp:Label ID="Student_NameLabel" runat="server" Text='<%# Bind("[Student Name]") %>'></asp:Label></td>
</tr>
<tr>
<td style="width: 138px">
Grade:</td>
<td style="width: 108px">
<asp:Label ID="GradeLabel" runat="server" Text='<%# Bind("Grade") %>'></asp:Label></td>
</tr>
<tr>
<td style="width: 138px">
Date Recieved:</td>
<td style="width: 108px">
<asp:Label ID="Date_RecievedLabel" runat="server" Text='<%# Bind("[Date Recieved]") %>'></asp:Label></td>
</tr>
<tr>
<td colspan="2">
<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
Text="Edit"></asp:LinkButton>
<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
Text="Delete"></asp:LinkButton>
<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
Text="New"></asp:LinkButton></td>
</tr>
</table>
</ItemTemplate>
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<HeaderTemplate>
<span style="font-size: 16pt; color: #ffffff; font-family: Verdana">Lost and Found</span>
</HeaderTemplate>
</asp:FormView>
</td>
<td style="width: 100px; height: 257px">
</td>
</tr>
<tr>
<td style="width: 312px; height: 44px; text-align: right">
<asp:HyperLink ID="HyperLink1" runat="server" Font-Bold="True" Font-Names="Verdana"
Font-Size="Smaller" ImageUrl="~/Images/back.gif" NavigateUrl="~/Admin/Admin.aspx"
Style="text-align: right" Target="_parent"><< Back</asp:HyperLink></td>
<td style="width: 100px; height: 44px">
</td>
<td style="width: 100px; height: 44px">
</td>
<td style="width: 100px; height: 44px">
</td>
</tr>
</table>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:CortexConnectionString41 %>" DeleteCommand="DELETE FROM [LOST_FOUND] WHERE [Item ID] = @original_Item_ID AND [Date] = @original_Date AND [Book Title] = @original_Book_Title AND [Book Number] = @original_Book_Number AND [Student Name] = @original_Student_Name AND [Grade] = @original_Grade AND [Date Recieved] = @original_Date_Recieved"
InsertCommand="INSERT INTO [LOST_FOUND] ([Date], [Book Title], [Book Number], [Student Name], [Grade], [Date Recieved]) VALUES (@Date, @Book_Title, @Book_Number, @Student_Name, @Grade, @Date_Recieved)"
OldValuesParameterFormatString="{0}" SelectCommand="SELECT * FROM [LOST_FOUND] ORDER BY [Date]"
UpdateCommand="UPDATE [LOST_FOUND] SET [Date] = @Date, [Book Title] = @Book_Title, [Book Number] = @Book_Number, [Student Name] = @Student_Name, [Grade] = @Grade, [Date Recieved] = @Date_Recieved WHERE [Item ID] = @original_Item_ID AND [Date] = @original_Date AND [Book Title] = @original_Book_Title AND [Book Number] = @original_Book_Number AND [Student Name] = @original_Student_Name AND [Grade] = @original_Grade AND [Date Recieved] = @original_Date_Recieved">
<DeleteParameters>
<asp:Parameter Name="original_Item_ID" Type="Int32" />
<asp:Parameter Name="original_Date" Type="String" />
<asp:Parameter Name="original_Book_Title" Type="String" />
<asp:Parameter Name="original_Book_Number" Type="String" />
<asp:Parameter Name="original_Student_Name" Type="String" />
<asp:Parameter Name="original_Grade" Type="String" />
<asp:Parameter Name="original_Date_Recieved" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Date" Type="String" />
<asp:Parameter Name="Book_Title" Type="String" />
<asp:Parameter Name="Book_Number" Type="String" />
<asp:Parameter Name="Student_Name" Type="String" />
<asp:Parameter Name="Grade" Type="String" />
<asp:Parameter Name="Date_Recieved" Type="String" />
<asp:Parameter Name="original_Item_ID" Type="Int32" />
<asp:Parameter Name="original_Date" Type="String" />
<asp:Parameter Name="original_Book_Title" Type="String" />
<asp:Parameter Name="original_Book_Number" Type="String" />
<asp:Parameter Name="original_Student_Name" Type="String" />
<asp:Parameter Name="original_Grade" Type="String" />
<asp:Parameter Name="original_Date_Recieved" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Date" Type="String" />
<asp:Parameter Name="Book_Title" Type="String" />
<asp:Parameter Name="Book_Number" Type="String" />
<asp:Parameter Name="Student_Name" Type="String" />
<asp:Parameter Name="Grade" Type="String" />
<asp:Parameter Name="Date_Recieved" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</asp:Content>