Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Trouble with INSERT INTO table
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Trouble with INSERT INTO table

 Post Reply Post Reply
Author
joshualane View Drop Down
Newbie
Newbie


Joined: 04 July 2002
Location: United States
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote joshualane Quote  Post ReplyReply Direct Link To This Post Topic: Trouble with INSERT INTO table
    Posted: 22 December 2003 at 9:57am
I'm having some trouble with my code and I'm not sure what the issue is. Basically, I have a form that is passing the information on to another asp page in order to add the info to the database. The error that I'm getting states:

Number of query values and destination fields are not the same


I checked the code, but don't know what the issue is? I'm guessing it's something to do with the two date values, but I'm not sure.


StrSql = "INSERT INTO Clients (CLIENT_NAME, CLIENT_STREET, CLIENT_CITY, CLIENT_ZIP, CLIENT_PHONE, CLIENT_GeneratorID, CLIENT_StartDATE, CLIENT_StopDATE, CLIENT_DESC) VALUES ('" & chkString(request("NAME")) & "', '" & chkString(request("STREET")) & "', '" & chkString(request("CITY")) & "', '" & chkString(request("STATE")) & "', '" & chkString(request("ZIP")) & "', '" & chkString(request("PHONE")) & "', '" & chkString(request("GeneratorID")) & "', '" & chkString(request("StartDATE")) & "', '" & chkString(request("StopDATE")) & "', '" & chkString(request("DESC")) & "')"
Back to Top
joshualane View Drop Down
Newbie
Newbie


Joined: 04 July 2002
Location: United States
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote joshualane Quote  Post ReplyReply Direct Link To This Post Posted: 22 December 2003 at 10:40am
Never mind... I found a better way to handle the process thanks to a Web Wiz tutorial.

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 22 December 2003 at 3:53pm

and for future reference...

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

means that the # of items don't match, so in

INSERT INTO table (....these column names...) VALUES (...these values....)

don't have the same number or items, and directly from the code you posted:

Items in Column Name section of Insert:
CLIENT_NAME
CLIENT_STREET
CLIENT_CITY
CLIENT_ZIP
CLIENT_PHONE
CLIENT_GeneratorID
CLIENT_StartDATE
CLIENT_StopDATE
CLIENT_DESC

(9 items total)

Items in right side:
chkString(request("NAME"))
chkString(request("STREET"))
chkString(request("CITY"))
chkString(request("STATE"))
chkString(request("ZIP"))
chkString(request("PHONE"))
chkString(request("GeneratorID"))
chkString(request("StartDATE"))
chkString(request("StopDATE"))
chkString(request("DESC"))

(10 items)

since 9 != 10, SQL spit out that error and told you exactly what's wrong :)

 

Contribute to the working anarchy we fondly call the Internet
Back to Top
joshualane View Drop Down
Newbie
Newbie


Joined: 04 July 2002
Location: United States
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote joshualane Quote  Post ReplyReply Direct Link To This Post Posted: 22 December 2003 at 4:40pm
Yeah, I figured that out too once I started messing with the code some more. Oh well, perhaps next time I won't be so absent-minded and miss the completely obvious. Thanks for your help though, I appreciate it.
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 22 December 2003 at 6:19pm

nothing to be absent minded about...

just trust the error messages, read what they are telling you.....  makes programming a lot easier

Contribute to the working anarchy we fondly call the Internet
Back to Top
psycotik View Drop Down
Groupie
Groupie


Joined: 27 November 2003
Status: Offline
Points: 73
Post Options Post Options   Thanks (0) Thanks(0)   Quote psycotik Quote  Post ReplyReply Direct Link To This Post Posted: 22 December 2003 at 10:53pm

Also another thing is not to be afraid to divide the string into multiple lines.

sql = sql & "..."
sql = sql & "..."
sql = sql & "..."

Makes the sql alot easier to read/understand + change

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.