newmediaguy
Programmer
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?
Many thanks
Glen
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