Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > SQL syntax error in INSERT INTO statement

Reply
Thread Tools

SQL syntax error in INSERT INTO statement

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      07-01-2005
When trying to submit data to an Access database using ASP.NET I recieve the
following error:

[OleDbException (0x80040e14): Syntax error in INSERT INTO statement.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32 hr)
+41
System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS
dbParams, Object& executeResult) +174
System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult)
+92
System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior,
Object& executeResult) +65
System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
behavior, String method) +112
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +66
PAPresenters.register.btnSubmit_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\PAPresenters\register.aspx.vb:2 20
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292

The SQL in the CommandText property immediately before the the
ExecuteNonQuery method, which I got using Visual Studio's debugger, are:

>Debug.Print cmdSubmitToDB.CommandText


"INSERT INTO members
(organization,address1,city,state,zip,county,cell, email,password,membertype)
VALUES('Nate''s House','1234 My
House','MyCity','CA','12345','NONE','123-456-7890','(E-Mail Removed)','mypassword','artis tagent')"


What is wrong with the syntax in this statement? Is there any way I can have
be told where in the statement the error is? Thanks.
--
Nathan Sokalski
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
=?Utf-8?B?c3Jpbmk=?=
Guest
Posts: n/a
 
      07-01-2005
hi,
use [password] instead of password in the insert statement since password is
a reserved keyword.

--
The best
srini
http://www.expertszone.com


"Nathan Sokalski" wrote:

> When trying to submit data to an Access database using ASP.NET I recieve the
> following error:
>
> [OleDbException (0x80040e14): Syntax error in INSERT INTO statement.]
> System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32 hr)
> +41
> System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS
> dbParams, Object& executeResult) +174
> System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult)
> +92
> System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior,
> Object& executeResult) +65
> System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
> behavior, String method) +112
> System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +66
> PAPresenters.register.btnSubmit_Click(Object sender, EventArgs e) in
> c:\inetpub\wwwroot\PAPresenters\register.aspx.vb:2 20
> System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
> System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
> eventArgument) +57
> System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
> sourceControl, String eventArgument) +18
> System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
> System.Web.UI.Page.ProcessRequestMain() +1292
>
> The SQL in the CommandText property immediately before the the
> ExecuteNonQuery method, which I got using Visual Studio's debugger, are:
>
> >Debug.Print cmdSubmitToDB.CommandText

>
> "INSERT INTO members
> (organization,address1,city,state,zip,county,cell, email,password,membertype)
> VALUES('Nate''s House','1234 My
> House','MyCity','CA','12345','NONE','123-456-7890','(E-Mail Removed)','mypassword','artis tagent')"
>
>
> What is wrong with the syntax in this statement? Is there any way I can have
> be told where in the statement the error is? Thanks.
> --
> Nathan Sokalski
> (E-Mail Removed)
> http://www.nathansokalski.com/
>
>
>

 
Reply With Quote
 
 
 
 
Paul Clement
Guest
Posts: n/a
 
      07-01-2005
On Thu, 30 Jun 2005 23:48:02 -0700, "srini" <(E-Mail Removed)> wrote:

¤ hi,
¤ use [password] instead of password in the insert statement since password is
¤ a reserved keyword.

Sure is. You can always check the links below should you have any doubts:

List of Microsoft Jet 4.0 reserved words
http://support.microsoft.com/default...b;en-us;321266

List of reserved words in Access 2002 and Access 2003
http://support.microsoft.com/default...b;en-us;286335

ODBC Reserved Keywords
http://msdn.microsoft.com/library/de...d_keywords.asp


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      07-01-2005
Right and better yet setup a Parameter-driven Command instead of using ad
hoc queries--unless you don't care about SQL injection and a number of other
issues.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"srini" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> hi,
> use [password] instead of password in the insert statement since password
> is
> a reserved keyword.
>
> --
> The best
> srini
> http://www.expertszone.com
>
>
> "Nathan Sokalski" wrote:
>
>> When trying to submit data to an Access database using ASP.NET I recieve
>> the
>> following error:
>>
>> [OleDbException (0x80040e14): Syntax error in INSERT INTO statement.]
>> System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32
>> hr)
>> +41
>>
>> System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS
>> dbParams, Object& executeResult) +174
>> System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object&
>> executeResult)
>> +92
>> System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior
>> behavior,
>> Object& executeResult) +65
>> System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
>> behavior, String method) +112
>> System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +66
>> PAPresenters.register.btnSubmit_Click(Object sender, EventArgs e) in
>> c:\inetpub\wwwroot\PAPresenters\register.aspx.vb:2 20
>> System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
>>
>> System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
>> eventArgument) +57
>> System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
>> sourceControl, String eventArgument) +18
>> System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
>> +33
>> System.Web.UI.Page.ProcessRequestMain() +1292
>>
>> The SQL in the CommandText property immediately before the the
>> ExecuteNonQuery method, which I got using Visual Studio's debugger, are:
>>
>> >Debug.Print cmdSubmitToDB.CommandText

>>
>> "INSERT INTO members
>> (organization,address1,city,state,zip,county,cell, email,password,membertype)
>> VALUES('Nate''s House','1234 My
>> House','MyCity','CA','12345','NONE','123-456-7890','(E-Mail Removed)','mypassword','artis tagent')"
>>
>>
>> What is wrong with the syntax in this statement? Is there any way I can
>> have
>> be told where in the statement the error is? Thanks.
>> --
>> Nathan Sokalski
>> (E-Mail Removed)
>> http://www.nathansokalski.com/
>>
>>
>>



 
Reply With Quote
 
diverge diverge is offline
Junior Member
Join Date: Aug 2008
Posts: 1
 
      08-20-2008
I had the same problem where i have used :
Insert into table (password,...)
you must use :
Insert into table ([password],...) to have an valid sql expression

tnx
 
Reply With Quote
 
ahmed_samir ahmed_samir is offline
Junior Member
Join Date: Sep 2010
Posts: 1
 
      09-03-2010
my statment is like that

d = "insert into cv1(name,birth,country,city,address,tel,school,spc h,quali,email,pers,user)values('" + nme.Text + "','" + birth.Text + "','" + country.Text + "','" + city.Text + "','" + address.Text + "','" + tel.Text + "','" + school.Text + "','" + spech.Text + "','" + quali.Text + "','" + email.Text + "','" + pers.Text + "','" + user.Text + "')"

and my proplem is :
when i start debuging an error happen which is syntax error INSERT INTO statement and the program highlight the cmd.excutenonquery() statment
so if any one can help me in this problem



Ahmed Samir
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
-2147217900:Syntax error in INSERT INTO statement. solomon_13000 ASP General 1 10-02-2006 07:08 PM
Syntax error in INSERT INTO statement Gérard Leclercq ASP General 6 02-02-2005 03:11 PM
password field: Syntax error in INSERT INTO statement. Neil Zanella ASP .Net 3 01-25-2005 02:49 AM
Syntax error in INSERT INTO statement Saber ASP .Net 5 07-20-2004 11:26 AM
adapter update problem Syntax error in INSERT INTO statement. compuglobalhypermeganetz0r ASP .Net 0 12-08-2003 05:03 AM



Advertisments