Active Server Pages

Moderators: None (Apply to moderate this forum)
Number of threads: 1763
Number of posts: 4498

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
ASP and INSERT SQL statement Posted by Ribbleton on 23 Mar 2006 at 12:22 PM
Basically when i do a response.write to my query string, then copy it and run it in my Access database as a SQL statement it works. However when i try and run it from my ASP page i get the error:

Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error in INSERT INTO statement.

but the syntax can't have a error because it works when i run it on the database it works.

my code is:

sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _ 
	"Data Source=" & Server.MapPath("database.mdb") 
	
	Set connection = Server.CreateObject("ADODB.Connection")
	connection.Mode = 3				'allow writable
	connection.Open(sConnString)
	

    strQuery = "INSERT INTO Customer  (username, password, Customer_FirstName, Customer_Surname, Address1, Address2, Town, Postcode, Tel, Email, SortCode, AccountNumber, PaymentTypeId) VALUES ( 'robbie', 'password', 'name', 'name1', 'add1', 'add2', 'town', 'post', 'tel', 'email', '111111', '33232', '1'); "
    
   ' Response.Write(strQuery)
	connection.Execute(strQuery)


The only row missing is the primary key and that is of type auto number.

Thanks in advance.

*Ribbleton_

Report
Re: ASP and INSERT SQL statement Posted by aaronjones3593 on 23 Mar 2006 at 5:26 PM
: Basically when i do a response.write to my query string, then copy it and run it in my Access database as a SQL statement it works. However when i try and run it from my ASP page i get the error:
:
: Error Type:
: Microsoft JET Database Engine (0x80040E14)
: Syntax error in INSERT INTO statement.
:
: but the syntax can't have a error because it works when i run it on the database it works.
:
: my code is:
:
:
: sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _ 
: 	"Data Source=" & Server.MapPath("database.mdb") 
: 	
: 	Set connection = Server.CreateObject("ADODB.Connection")
: 	connection.Mode = 3				'allow writable
: 	connection.Open(sConnString)
: 	
: 
:     strQuery = "INSERT INTO Customer  (username, password, Customer_FirstName, Customer_Surname, Address1, Address2, Town, Postcode, Tel, Email, SortCode, AccountNumber, PaymentTypeId) VALUES ( 'robbie', 'password', 'name', 'name1', 'add1', 'add2', 'town', 'post', 'tel', 'email', '111111', '33232', '1'); "
:     
:    ' Response.Write(strQuery)
: 	connection.Execute(strQuery)
: 

:
: The only row missing is the primary key and that is of type auto number.
:
: Thanks in advance.
:
: *Ribbleton_
:

You mean coloumn?

Try including that in there and setting the value as '' for it.
I think that solved a similar problem I had...

-( Aaron )-

"Alcohol aint the answer, but atleast you forget the question"




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.