Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 7th, 2003, 12:34 PM
Registered User
 
Join Date: Aug 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to joshua_mccrea Send a message via MSN to joshua_mccrea
Default ASP Insert into command

Hello everyboy, this is my first time using this service and hope to use it more often. I've been working on this problem for a few hours now and can't seem to come up with any reason why it won't work. My code:

SQL = "INSERT into LOCATION (Location_ID,Locations,Location_Label,Location_Des cription,"
SQL = SQL & "County,Route,Begin_Log,End_Log,SECT_Length,Type_C ode,NLF_ID)"
SQL = SQL & " VALUES "
SQL = SQL & "('" & LocationID & "," & Location & "',"
SQL = SQL & "'" & LocLabel & "," & Request("LocDesc") & "',"
SQL = SQL & "'" & Request("County") & "," & Request("Route") & "',"
SQL = SQL & "'" & BeginLog2 & "," & EndLog2 & "',"
SQL = SQL & "'" & Section & "," & Request("FundType") & "',"
SQL = SQL & "'" & NLFID & "')"
response.write SQL
Set rs= adoDataConn.execute(SQL)


And the printout from the SQL print is:

INSERT into LOCATION (Location_ID,Locations,Location_Label,Location_Des cription,County,Route,Begin_Log,End_Log,SECT_Lengt h,Type_Code,NLF_ID) VALUES ('DEL04204000600,DEL-US-42','DEL-US-42 04.00-06.00,By the Zoo','DEL,42','04.00,06.00','02.00,F','SDELUS00042 **C')

I get an error explaining that the number of query values and the number of destination fields are not equal. I've counted them up and I get 11 fields in the table and 11 variables that I'm trying to insert. I'd appreciate any help on this matter.

Thanks
 
Old August 7th, 2003, 12:42 PM
Authorized User
 
Join Date: Aug 2003
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually if you carefully take a look at your printed out sql statement its like this:

INSERT into LOCATION (Location_ID,Locations,Location_Label,Location_Des cription,County,Route,Begin_Log,End_Log,SECT_Lengt h,Type_Code,NLF_ID) VALUES ('DEL04204000600,DEL-US-42','DEL-US-42 04.00-06.00,By the Zoo','DEL,42','04.00,06.00','02.00,F','SDELUS00042 **C')

and 'DEL0420...,DEL-US-42' is considered as one field as the first field is not ended bu a quote, nor the second field started with a quote, rather you joined them as one field by bringing them together into one set of quotes. got it? just re write the sql and it should work.

Chintu

 
Old August 7th, 2003, 12:53 PM
Registered User
 
Join Date: Aug 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to joshua_mccrea Send a message via MSN to joshua_mccrea
Default

Thanks chintu, that fixed that problem pretty quick. I had noticed those quotes but wasn't thinking straight, and didn't really take them into consideration.

 
Old August 7th, 2003, 01:13 PM
Registered User
 
Join Date: Aug 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to joshua_mccrea Send a message via MSN to joshua_mccrea
Default

I guess that one problem seems to breed other problems. Now I'm looking at an error message:

Microsoft JET Database Engine error '80040e14'

Syntax error (missing operator) in query expression 'DEL-US-42 04.00-06.00'.

/locations.asp, line 116

I'm using the same code except the changes to do away with the single quotes.

 
Old August 7th, 2003, 02:26 PM
Authorized User
 
Join Date: Aug 2003
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

can u response.write the sql query? and possibly post it here...

Chintu

 
Old August 13th, 2003, 10:35 PM
Authorized User
 
Join Date: Jun 2003
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to planeswalk
Default

Hi,

Just make sure that you check whether each entry in your SQL statement is fully enclosed by single-quotes. Looking at your original SQL statement I see a lot of values that are not fully enclosed by single quotes so you have to really check each and every entry.

Cheers!


Marlon Villarama
Support Team
Web Burner Hosting
[email protected]
www.webburner.com
Toll-Free: 877-535-2876





Similar Threads
Thread Thread Starter Forum Replies Last Post
insert command in grid view sumit_0 ASP.NET 2.0 Basics 1 April 26th, 2008 05:05 AM
Having Problems with my Insert Command - RESOLVED Andrew.Berry ASP.NET 2.0 Basics 1 October 2nd, 2007 09:59 AM
Insert Command using a querystring Andrew.Berry ASP.NET 2.0 Basics 1 September 27th, 2007 09:26 AM
Variable Usage in Insert Command tara0308 Access VBA 7 July 30th, 2007 12:50 PM
Insert command rajanikrishna ASP.NET 1.0 and 1.1 Basics 0 April 3rd, 2006 08:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.