Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL 2000 Insert Error from ASP 1

Status
Not open for further replies.

newmediaguy

Programmer
Mar 26, 2004
176
GB
Hi Guys,

I have an ASP page that inserts multiple rows through a looping ASP function, the problem is that it says the amount of columns and values don't match however when I print the queries out the colum and value counts are the same.......any suggestions?

Code:
' Application
' allow users to enter quote - once only
'''''''''''''''''''''''''''''''''''''''''''''''''''''

' Get and split the array
dim catsel
dim catarray
catsel = Request.Form("cat")
										
catsel = trim(catsel)
catsel = replace(catsel," ", "")
catarray = split(catsel,",")
' debug - check array values and size manually
'''''''''''''''''''''''''''''''''''''''''
Response.Write("<br>"&catsel & "<br>")

' write them out for debugging
''''''''''''''''''''''''''''''''''''''''''
counter = 0
for l=0 to ubound(catarray)
counter = counter+1
Response.Write(counter-1&"userdetails ")


' Sql and Loop variables to perform insert
'''''''''''''''''''''''''''''''''''''''''''
sql = "INSERT INTO QuoteDetails (qID,UserName,UserEmail,UserNo,Company,Manufacturer,category,details,manPn,qty,PriceQuote,Date_Time)"
sql=sql & " VALUES "
sql=sql & "('" & Request.form("qID")& ","
sql=sql & Request.form("username")& ","
sql=sql & Request.form("useremail")& ","
sql=sql & Request.form("userno")& ","
sql=sql & Request.form("company")& ","
sql=sql & Request.form(counter-1&"menu1")& ","
sql=sql & Request.form(counter-1&"category")& ","
sql=sql & Request.form(counter-1&"details")& ","
sql=sql & Request.form(counter-1&"manpn")& ","
sql=sql & Request.form(counter-1&"qty")& ","
sql=sql & Request.form(counter-1&"price")& ","
sql=sql & Request.form(counter-1&"datetime")& "')"

'Debug and write query string out for each item
'''''''''''''''''''''''''''''''''''''''''''''''
Response.Write("sql: "&sql&"<br>")

'open connection and execute if var present in string
'''''''''''''''''''''''''''''''''''''''''''''''

	if Request.QueryString("insert") = 1 then
	set conn = server.CreateObject("ADODB.Connection")	conn.Open MM_pcdisql_STRING
	conn.Execute (""&sql&"")
	conn.Close()
	else
	end if

next

Many thanks
Glen
 
You have one pair of single inverted commas, starting before your first "value" and finishing after your last "value". Therefore the SQL parser sees one value only: a long string.

Have fun
Simon
 
Thanks Simon,

A classic case of wood for the trees there I think!

:p

Thanks again

Glen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top