473,770 Members | 4,553 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error Updating SQL DB

1 New Member
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.Sql Client.SqlExcep tion: 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.Sql Client.SqlConne ction.OnError(S qlException exception, Boolean breakConnection ) +177
System.Data.Sql Client.SqlInter nalConnection.O nError(SqlExcep tion exception, Boolean breakConnection ) +68
System.Data.Sql Client.TdsParse r.ThrowExceptio nAndWarning(Tds ParserStateObje ct stateObj) +199
System.Data.Sql Client.TdsParse r.Run(RunBehavi or runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleR esultSet bulkCopyHandler , TdsParserStateO bject stateObj) +2305
System.Data.Sql Client.SqlComma nd.FinishExecut eReader(SqlData Reader ds, RunBehavior runBehavior, String resetOptionsStr ing) +147
System.Data.Sql Client.SqlComma nd.RunExecuteRe aderTds(Command Behavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1021
System.Data.Sql Client.SqlComma nd.RunExecuteRe ader(CommandBeh avior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +314
System.Data.Sql Client.SqlComma nd.InternalExec uteNonQuery(DbA syncResult result, String methodName, Boolean sendToPipe) +413
System.Data.Sql Client.SqlComma nd.ExecuteNonQu ery() +115
System.Web.UI.W ebControls.SqlD ataSourceView.E xecuteDbCommand (DbCommand command, DataSourceOpera tion operation) +392
System.Web.UI.W ebControls.SqlD ataSourceView.E xecuteUpdate(ID ictionary keys, IDictionary values, IDictionary oldValues) +643
System.Web.UI.D ataSourceView.U pdate(IDictiona ry keys, IDictionary values, IDictionary oldValues, DataSourceViewO perationCallbac k callback) +78
System.Web.UI.W ebControls.Form View.HandleUpda te(String commandArg, Boolean causesValidatio n) +1151
System.Web.UI.W ebControls.Form View.HandleEven t(EventArgs e, Boolean causesValidatio n, String validationGroup ) +450
System.Web.UI.W ebControls.Form View.OnBubbleEv ent(Object source, EventArgs e) +88
System.Web.UI.C ontrol.RaiseBub bleEvent(Object source, EventArgs args) +35
System.Web.UI.W ebControls.Form ViewRow.OnBubbl eEvent(Object source, EventArgs e) +109
System.Web.UI.C ontrol.RaiseBub bleEvent(Object source, EventArgs args) +35
System.Web.UI.W ebControls.Link Button.OnComman d(CommandEventA rgs e) +86
System.Web.UI.W ebControls.Link Button.RaisePos tBackEvent(Stri ng eventArgument) +156
System.Web.UI.W ebControls.Link Button.System.W eb.UI.IPostBack EventHandler.Ra isePostBackEven t(String eventArgument) +7
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler sourceControl, String eventArgument) +11
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +172
System.Web.UI.P age.ProcessRequ estMain(Boolean includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +4921


Here is my code

<%@ Page Language="VB" MasterPageFile= "~/MasterPage.mast er" AutoEventWireup ="false" CodeFile="LostA ndFound.aspx.vb " Inherits="Defau lt2" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHol derID="ContentP laceHolder1" 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;">
&nbsp;&nbsp;&nb sp; &nbsp;&nbsp;&nb sp;
<asp:FormView ID="FormView1" runat="server" CellPadding="4" DataKeyNames="I tem ID"
DataSourceID="S qlDataSource1" ForeColor="#333 333">
<FooterStyle BackColor="#990 000" Font-Bold="True" ForeColor="Whit e" />
<EditItemTempla te>
<table>
<tr>
<td style="width: 156px">
Item ID:
</td>
<td style="width: 100px">
<asp:Label ID="Item_IDLabe l1" 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_TitleT extBox" 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_Number TextBox" 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_Nam eTextBox" runat="server" Text='<%# Bind("[Student Name]") %>'></asp:TextBox></td>
</tr>
<tr>
<td style="width: 156px">
Grade:
</td>
<td style="width: 100px">
<asp:TextBox ID="GradeTextBo x" 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_Reciev edTextBox" runat="server" Text='<%# Bind("[Date Recieved]") %>'></asp:TextBox></td>
</tr>
<tr>
<td colspan="2">
<asp:LinkButt on ID="UpdateButto n" runat="server" CausesValidatio n="True" CommandName="Up date"
Text="Update"></asp:LinkButton>
<asp:LinkButt on ID="UpdateCance lButton" runat="server" CausesValidatio n="False" CommandName="Ca ncel"
Text="Cancel"></asp:LinkButton> </td>
</tr>
</table>
</EditItemTemplat e>
<RowStyle BackColor="#FFF BD6" ForeColor="#333 333" />
<PagerStyle BackColor="#FFC C66" ForeColor="#333 333" HorizontalAlign ="Center" />
<InsertItemTemp late>
<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_TitleT extBox" 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_Number TextBox" 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_Nam eTextBox" runat="server" Text='<%# Bind("[Student Name]") %>'></asp:TextBox></td>
</tr>
<tr>
<td style="width: 153px">
Grade:</td>
<td style="width: 100px">
<asp:TextBox ID="GradeTextBo x" 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_Reciev edTextBox" runat="server" Text='<%# Bind("[Date Recieved]") %>'></asp:TextBox></td>
</tr>
<tr>
<td colspan="2">
<asp:LinkButt on ID="InsertButto n" runat="server" CausesValidatio n="True" CommandName="In sert"
Text="Insert"></asp:LinkButton>
<asp:LinkButt on ID="InsertCance lButton" runat="server" CausesValidatio n="False" CommandName="Ca ncel"
Text="Cancel"></asp:LinkButton> </td>
</tr>
</table>
</InsertItemTempl ate>
<ItemTemplate >
<table>
<tr>
<td style="width: 138px">
Item ID:
</td>
<td style="width: 108px">
<asp:Label ID="Item_IDLabe l" 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_TitleL abel" 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_Number Label" 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_Nam eLabel" 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_Reciev edLabel" runat="server" Text='<%# Bind("[Date Recieved]") %>'></asp:Label></td>
</tr>
<tr>
<td colspan="2">
<asp:LinkButt on ID="EditButton " runat="server" CausesValidatio n="False" CommandName="Ed it"
Text="Edit"></asp:LinkButton>
<asp:LinkButt on ID="DeleteButto n" runat="server" CausesValidatio n="False" CommandName="De lete"
Text="Delete"></asp:LinkButton>
<asp:LinkButt on ID="NewButton" runat="server" CausesValidatio n="False" CommandName="Ne w"
Text="New"></asp:LinkButton> </td>
</tr>
</table>
</ItemTemplate>
<HeaderStyle BackColor="#990 000" Font-Bold="True" ForeColor="Whit e" />
<HeaderTemplate >
<span style="font-size: 16pt; color: #ffffff; font-family: Verdana">Lost and Found</span>
</HeaderTemplate>
</asp:FormView>
&nbsp;
</td>
<td style="width: 100px; height: 257px">
</td>
</tr>
<tr>
<td style="width: 312px; height: 44px; text-align: right">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<asp:HyperLin k 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:SqlDataSou rce ID="SqlDataSour ce1" runat="server" ConflictDetecti on="CompareAllV alues"
ConnectionStrin g="<%$ ConnectionStrin gs:CortexConnec tionString41 %>" 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_Stude nt_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) "
OldValuesParame terFormatString ="{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_Stude nt_Name AND [Grade] = @original_Grade AND [Date Recieved] = @original_Date_ Recieved">
<DeleteParamete rs>
<asp:Paramete r Name="original_ Item_ID" Type="Int32" />
<asp:Paramete r Name="original_ Date" Type="String" />
<asp:Paramete r Name="original_ Book_Title" Type="String" />
<asp:Paramete r Name="original_ Book_Number" Type="String" />
<asp:Paramete r Name="original_ Student_Name" Type="String" />
<asp:Paramete r Name="original_ Grade" Type="String" />
<asp:Paramete r Name="original_ Date_Recieved" Type="String" />
</DeleteParameter s>
<UpdateParamete rs>
<asp:Paramete r Name="Date" Type="String" />
<asp:Paramete r Name="Book_Titl e" Type="String" />
<asp:Paramete r Name="Book_Numb er" Type="String" />
<asp:Paramete r Name="Student_N ame" Type="String" />
<asp:Paramete r Name="Grade" Type="String" />
<asp:Paramete r Name="Date_Reci eved" Type="String" />
<asp:Paramete r Name="original_ Item_ID" Type="Int32" />
<asp:Paramete r Name="original_ Date" Type="String" />
<asp:Paramete r Name="original_ Book_Title" Type="String" />
<asp:Paramete r Name="original_ Book_Number" Type="String" />
<asp:Paramete r Name="original_ Student_Name" Type="String" />
<asp:Paramete r Name="original_ Grade" Type="String" />
<asp:Paramete r Name="original_ Date_Recieved" Type="String" />
</UpdateParameter s>
<InsertParamete rs>
<asp:Paramete r Name="Date" Type="String" />
<asp:Paramete r Name="Book_Titl e" Type="String" />
<asp:Paramete r Name="Book_Numb er" Type="String" />
<asp:Paramete r Name="Student_N ame" Type="String" />
<asp:Paramete r Name="Grade" Type="String" />
<asp:Paramete r Name="Date_Reci eved" Type="String" />
</InsertParameter s>
</asp:SqlDataSour ce>
</asp:Content>

Jun 25 '07 #1
3 1882
kenobewan
4,871 Recognized Expert Specialist
Welcome to TSDN. I'm not sure why you pasted so much code. You'll need to debug the sql and work out which variable is the problem, I can't tell which it is by your code.
Jun 25 '07 #2
Wing
28 New Member
Your error is going to be on LostAndFound.as px.vb dealing with SQL statement near 'nvarchar' Since you are using ASP use Response.Write to display your SQL statement before committing it the database.
Jun 25 '07 #3
Frinavale
9,735 Recognized Expert Moderator Expert
That certainly is a lot of code!
What we really need to see is your VB code (not the HTML) that you have written to connect to your database.

Please only post that code snippet and please use [code=vbnet] ...your code [ /code]

Thanks

-Frinny
Jun 25 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
4380
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two files containing some templates: adjacency_list.hpp and mem_fn.hpp can not compile. Does anyone have any solutions?
5
7824
by: azgoddess1 | last post by:
During the installation I get these error messages: ***** SQL1390C The environment variable DB2Instance is not defined or is invalid An error ocured while loading the command "C:\Program Files\IBM\SQLLIB\bin\db2.exe CREATE TOOLS CATALOG SYSTOOLS USE EXISITING DATABASE DWCTRLDB FORCE" to initialize and\or migrate the DB2 tools catalog database. The return value is "5104".
18
9045
by: Steve | last post by:
Hi I have a really weird problem and any assistance would be welcome. I have developed an app in Access 2002. The app runs perfectly on the development machine. I have packaged the app using the Microsoft XP Developer Packaging Wizard (Service Pack 1). The 1st 3 releases of the app ran perfectly on site.
0
1146
by: Ryan Dawson | last post by:
Hello. I am getting an error when trying to remove/access items inside of a listview: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: '500' is not a valid value for 'displayIndex'. I only remove item 500 from the listview if the number of items is greater than 500 (so it removes the last item). Also, I am updating items in the listview with code:
6
9662
by: akoymakoy | last post by:
Run time error 3251 Current Recordset does not support updating, this may be a limitation of the provider, or of the selected Locktype This is my simple program that will split the entries that have 2 words in it and put it in separate fields: im using MSaccess for my tables for example: before field1= word1, word2
3
616
by: amatuer | last post by:
ADODB.Recordset error '800a0cb3' Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype. /devag/newProjSave.asp, line 321 sqlOCF = "SELECT * FROM DA_OtherCFacilities" set rstOCF = CreateObject("ADODB.Recordset")
10
1689
by: Mike | last post by:
I have code that is doing some updating to a record. Its getting the ID to update from the Grid. I'm passing an INT to my method to update the record. My code is working though I'm still getting an 'input string was not in a correct format.' Code: foreach (GridViewRow row in grid.Rows) { CheckBox chk = (CheckBox)gr.FindControl("checkbox"); if (chk.Checked) {
0
2918
by: mbenedict | last post by:
I am rather new at this code and am attempting to modify existing code to use clob datatypes, which I have never used before. The database tables have been set up for clob data. When trying to use dbms_lob.writeappend, I am getting the following error..Command text was not set for the command object. I've researched this in the net as much as I could, but I'm lost in what I am doing wrong. Can you help please? Here is my code... ...
0
3960
by: Toralf Kirsten | last post by:
Hi all, we have installed DB2 V9.5 Trial on a Fedora 6 Linux box (32bit). Since the box is included in a NIS we have manually created db2 users db2inst, dasusr and db2fenc on this box (not in the NIS). The installation process is carried out by using the root user (as root, not using sudo or something else). We selected the custom installation and de-selected the SA MP option but enabled the option to build the TOOLSDB (catalog db as I...
2
1824
by: Smurfas | last post by:
What's wrong? Compiletor don't show anything, but whet I start program show this error: "Error updating the employee details!" protected void Button1_Click(object sender, EventArgs e) { //416 puslapis // Declare objects SqlConnection conn;
0
9602
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10237
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9882
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8905
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.