navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Query Values

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Query Values
Page: [1]
 
kitty6

 

Posts: 148
Joined: 10/15/2005
Status: offline

 
Query Values - 6/10/2008 13:15:52   
I have a form which posts to a file called submitout.asp
I get the following error:

Number of query values and destination fields are not the same.

Does anyone know why? Thanks.

Here is the code in submitout.asp

mySQL = "INSERT INTO results (Name,HowLong,Reason) VALUES ('"
mySQL = mySQL & StripQuote(Request.Form("Name")) & "','" & StripQuote(Request.Form("HowLong")) & "','" & StripQuote(Request.Form("Reason")) & "','"

'Response.write(mySQL)
'Response.end

set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
conntemp.execute(mySQL)
conntemp.close




BeTheBall

 

Posts: 6359
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Query Values - 6/10/2008 14:46:38   
Yes. I know why . . .

Oh, you probably want me to tell you why. You have an extra comma near the end of your SQL so the code expects another value. Try changing the SQL line to:

mySQL = "INSERT INTO results (Name,HowLong,Reason) VALUES ('"
mySQL = mySQL & StripQuote(Request.Form("Name")) & "','" & StripQuote(Request.Form("HowLong")) & "','" & StripQuote(Request.Form("Reason")) & "'"

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to kitty6)
kitty6

 

Posts: 148
Joined: 10/15/2005
Status: offline

 
RE: Query Values - 6/10/2008 18:06:35   
Now when I fill in the form with aaa, I get the following error?

Syntax error in string in query expression ''aaa'''.

(in reply to BeTheBall)
BeTheBall

 

Posts: 6359
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Query Values - 6/10/2008 22:54:10   
and this?

mySQL = "INSERT INTO results (Name,HowLong,Reason) VALUES ('"
mySQL = mySQL & StripQuote(Request.Form("Name")) & "','" & StripQuote(Request.Form("HowLong")) & "','" & StripQuote(Request.Form("Reason")) & "')"

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to kitty6)
kitty6

 

Posts: 148
Joined: 10/15/2005
Status: offline

 
RE: Query Values - 6/16/2008 8:56:38   
Ok, that worked but I added some more fields and changed some things around a bit and now get this error? What am I missing? Thanks.

Microsoft JET Database Engine error '80040e14'

Syntax error in INSERT INTO statement.

/submitout.asp, line 25

Here is my code:

mySQL = "INSERT INTO results (Name,Reason,Option) VALUES ('"
mySQL = mySQL & StripQuote(Request.Form("Name")) & "','" & StripQuote(Request.Form("Reason")) & "','" & StripQuote(Request.Form("Option")) & "')"

set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
conntemp.execute(mySQL)
conntemp.clos

(in reply to BeTheBall)
BeTheBall

 

Posts: 6359
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Query Values - 6/16/2008 9:43:14   
Name is a reserved word and should be avoided as a field name in your database. However, if you must use it, then you must put brackets around it in your SQL. For example:

mySQL = "INSERT INTO results ([Name],Reason,Option) VALUES ('"
mySQL = mySQL & StripQuote(Request.Form("Name")) & "','" & StripQuote(Request.Form("Reason")) & "','" & StripQuote(Request.Form("Option")) & "')"

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to kitty6)
kitty6

 

Posts: 148
Joined: 10/15/2005
Status: offline

 
RE: Query Values - 6/16/2008 11:25:56   
Ok, I changed it to person instead of name and below is the code but still getting this error:

Syntax error in INSERT INTO statement.

mySQL = "INSERT INTO results (Person,Reason,Category,In,Back) VALUES ('"
mySQL = mySQL & StripQuote(Request.Form("Person")) & "','" & StripQuote(Request.Form("Reason")) & "','" & StripQuote(Request.Form("Category")) & "','" & StripQuote(Request.Form("In")) & "','" & StripQuote(Request.Form("Back")) & "')"

Thanks.

(in reply to BeTheBall)
BeTheBall

 

Posts: 6359
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Query Values - 6/16/2008 14:35:08   
Pretty sure "In" will be a reserved word as well. Try putting that in brackets:

mySQL = "INSERT INTO results (Person,Reason,Category,[In],Back) VALUES ('"
mySQL = mySQL & StripQuote(Request.Form("Person")) & "','" & StripQuote(Request.Form("Reason")) & "','" & StripQuote(Request.Form("Category")) & "','" & StripQuote(Request.Form("In")) & "','" & StripQuote(Request.Form("Back")) & "')"

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to kitty6)
kitty6

 

Posts: 148
Joined: 10/15/2005
Status: offline

 
RE: Query Values - 6/16/2008 18:53:02   
Thanks, that did it.

One more question. How would I pass a hidden fields value? I added the field "Time" but got an error. How would my code look if I used the that field "Time"?

Thanks for all your help!

(in reply to BeTheBall)
BeTheBall

 

Posts: 6359
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Query Values - 6/17/2008 0:10:57   
Time may also be a reserved word. Also, if this is an Access db, then you need to use different delimiters on your field. Something like:

mySQL = "INSERT INTO results (Person,Reason,Category,[In],Back,[Time]) VALUES ('"
mySQL = mySQL & StripQuote(Request.Form("Person")) & "','" & StripQuote(Request.Form("Reason")) & "','" & StripQuote(Request.Form("Category")) & "','" & StripQuote(Request.Form("In")) & "','" & StripQuote(Request.Form("Back")) & "',#" & StripQuote(Request.Form("Time")) & "#)"

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to kitty6)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Query Values
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts