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.
Author |
Topic |
Trez
Starting Member
4 Posts |
Posted - 2007-06-21 : 02:36:35
|
Hey, Am new using ASP.NET and am getting this error when i try to update data in SQL DB.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) +2305 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) +1150 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) +85 System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +155 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) +170 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4921 |
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2007-06-21 : 11:58:15
|
Can you post your code? |
 |
|
Trez
Starting Member
4 Posts |
Posted - 2007-06-21 : 20:42:55
|
Here is my codes, i really hope you can help me....Thanx ahead.<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Books.aspx.vb" Inherits="Default2" title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <table> <tr> <td style="width: 307px"> </td> <td style="width: 100px"> </td> <td style="width: 100px"> </td> <td style="width: 100px"> </td> </tr> <tr> <td style="width: 307px"> </td> <td colspan="2" style="text-align: center"> <span style="font-size: 14pt; color: olive; font-family: Verdana"><strong>Edit Book Information</strong></span></td> <td style="width: 100px"> </td> </tr> <tr> <td style="width: 307px"> </td> <td style="width: 100px"> </td> <td style="width: 100px"> </td> <td style="width: 100px"> </td> </tr> <tr> <td style="width: 307px; height: 376px;"> </td> <td colspan="2" style="vertical-align: top; height: 376px; text-align: left"> <asp:FormView ID="FormView1" runat="server" CellPadding="4" DataKeyNames="Book ID" DataSourceID="SqlDataSource1" ForeColor="#333333"> <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /> <EditItemTemplate> Book ID: <asp:Label ID="Book_IDLabel1" runat="server" Text='<%# Eval("[Book ID]") %>'></asp:Label><br /> ISBN No#: <asp:TextBox ID="ISBN_No_TextBox" runat="server" Text='<%# Bind("[ISBN No#]") %>'> </asp:TextBox><br /> Book Title: <asp:TextBox ID="Book_TitleTextBox" runat="server" Text='<%# Bind("[Book Title]") %>'> </asp:TextBox><br /> Publishers: <asp:TextBox ID="PublishersTextBox" runat="server" Text='<%# Bind("Publishers") %>'> </asp:TextBox><br /> Year Pulbished: <asp:TextBox ID="Year_PulbishedTextBox" runat="server" Text='<%# Bind("[Year Pulbished]") %>'> </asp:TextBox><br /> Quantity: <asp:TextBox ID="QuantityTextBox" runat="server" Text='<%# Bind("Quantity") %>'> </asp:TextBox><br /> Remark: <asp:TextBox ID="RemarkTextBox" runat="server" Text='<%# Bind("Remark") %>'> </asp:TextBox><br /> <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> </EditItemTemplate> <RowStyle BackColor="#FFFBD6" ForeColor="#333333" /> <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" /> <InsertItemTemplate> ISBN No#: <asp:TextBox ID="ISBN_No_TextBox" runat="server" Text='<%# Bind("[ISBN No#]") %>'> </asp:TextBox><br /> Book Title: <asp:TextBox ID="Book_TitleTextBox" runat="server" Text='<%# Bind("[Book Title]") %>'> </asp:TextBox><br /> Publishers: <asp:TextBox ID="PublishersTextBox" runat="server" Text='<%# Bind("Publishers") %>'> </asp:TextBox><br /> Year Pulbished: <asp:TextBox ID="Year_PulbishedTextBox" runat="server" Text='<%# Bind("[Year Pulbished]") %>'> </asp:TextBox><br /> Quantity: <asp:TextBox ID="QuantityTextBox" runat="server" Text='<%# Bind("Quantity") %>'> </asp:TextBox><br /> Remark: <asp:TextBox ID="RemarkTextBox" runat="server" Text='<%# Bind("Remark") %>'> </asp:TextBox><br /> <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> </InsertItemTemplate> <ItemTemplate> Book ID: <asp:Label ID="Book_IDLabel" runat="server" Text='<%# Eval("[Book ID]") %>'></asp:Label><br /> ISBN No#: <asp:Label ID="ISBN_No_Label" runat="server" Text='<%# Bind("[ISBN No#]") %>'></asp:Label><br /> Book Title: <asp:Label ID="Book_TitleLabel" runat="server" Text='<%# Bind("[Book Title]") %>'> </asp:Label><br /> Publishers: <asp:Label ID="PublishersLabel" runat="server" Text='<%# Bind("Publishers") %>'> </asp:Label><br /> Year Pulbished: <asp:Label ID="Year_PulbishedLabel" runat="server" Text='<%# Bind("[Year Pulbished]") %>'> </asp:Label><br /> Quantity: <asp:Label ID="QuantityLabel" runat="server" Text='<%# Bind("Quantity") %>'></asp:Label><br /> Remark: <asp:Label ID="RemarkLabel" runat="server" Text='<%# Bind("Remark") %>'></asp:Label><br /> <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> </ItemTemplate> <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /> </asp:FormView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CortexConnectionString33 %>" SelectCommand="SELECT BOOK.* FROM BOOK" UpdateCommand="UPDATE BOOK SET [ISBN No#] =@[ISBN No#], [Book Title] =@[Book Title], Publishers =@Publicher, [Year Pulbished] =@[Year Published], Quantity =@Quantity, Remark =@Remark"> <UpdateParameters> <asp:Parameter /> <asp:Parameter Name="Publicher" /> <asp:Parameter Name="Quantity" /> <asp:Parameter Name="Remark" /> </UpdateParameters> </asp:SqlDataSource> </td> <td style="width: 100px; height: 376px;"> </td> </tr> <tr> <td style="width: 307px; height: 32px; 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" Target="_parent"><< Back</asp:HyperLink></td> <td colspan="2" style="height: 32px"> </td> <td style="width: 100px; height: 32px"> </td> </tr> </table></asp:Content>[/red] |
 |
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2007-06-22 : 10:45:40
|
My guess is the error is occuring in this code, which certainly could not run on SQL Server:UPDATE BOOKSET [ISBN No#] =@[ISBN No#], [Book Title] =@[Book Title], Publishers =@Publicher, [Year Pulbished] =@[Year Published], Quantity =@Quantity, Remark =@Remark Unless your front end is manipulating this string before passing it to SQL Server, the database will not be able to interpret @[Field] as a value. And if your application is substituting actual values, then that is probably where the error is creeping in.And are these typos correct?Publishers =@Publicher[Year Pulbished] =@[Year Published] e4 d5 xd5 Nf6 |
 |
|
Trez
Starting Member
4 Posts |
Posted - 2007-06-24 : 22:20:01
|
Blindmanam going to look at it and see the typos are not correct i'll change them and see what happens |
 |
|
Trez
Starting Member
4 Posts |
Posted - 2007-06-26 : 02:03:18
|
I corrected everything, but now i get this errorwhat do you think the problem is now?ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'Update' that has parameters: Date, Book_Title, Book_Number, Student_Name, Grade, Date_Recieved, Original_Item_ID, [Book Title], [Book Number], [Student Name], [Date Recieved], Item ID. Exception Details: System.InvalidOperationException: ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'Update' that has parameters: Date, Book_Title, Book_Number, Student_Name, Grade, Date_Recieved, Original_Item_ID, [Book Title], [Book Number], [Student Name], [Date Recieved], Item ID. |
 |
|
|
|
|
|
|