Code not working.trying to insert values in database from form.Please help
I am trying to insert values from form into my database. I am using toad for sql and sql server 2005.I tried taking help from google but its not working.
It keep giving me ADODB.Recordset error '800a0e7d'
The connection cannot be used to perform this operation. It is either closed or invalid in this context.
this is my code
<%>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<%
Dim thedate,Email,Customer,Contact,Phone,Fax,Address,City,State,Zip,part1,qty1,invoice1,po1,date1,serial 1,problem1,part2,qty2,invoice2,po2,date2,serial2,problem2
Dim part3,qty3,invoice3,po3,date3,serial3,problem3,part4,qty4,invoice4,po4,date4,serial4,problem4,terms, delivery,comments
Dim sConnString, conn, sSQL, stSQL
Dim MyNewRandomNum
Randomize
MyNewRandomNum = Int(Rnd * 10000000)+1
thedate=Request.form("thedate")
Email=Request.form("Email")
Customer=Request.form("Customer")
Contact=Request.form("Contact")
Phone=Request.form("Phone")
Fax=Request.form("Fax")
Address=Request.form("Address")
City=Request.form("City")
State=Request.form("State")
Zip=Request.form("Zip")
part1=Request.form("part1")
qty1=Request.form("qty1")
invoice1=Request.form("invoice1")
po1=Request.form("po1")
date1=Request.form("date1")
serial1=Request.form("serial1")
problem1=Request.form("problem1")
part2=Request.form("part2")
qty2=Request.form("qty2")
invoice2=Request.form("invoice2")
po2=Request.form("po2")
date2=Request.form("date2")
serial2=Request.form("serial2")
problem2=Request.form("problem2")
part3=Request.form("part3")
qty3=Request.form("qty3")
invoice3=Request.form("invoice3")
po3=Request.form("po3")
date3=Request.form("date3")
serial3=Request.form("serial3")
problem3=Request.form("problem3")
part4=Request.form("part4")
qty4=Request.form("qty4")
invoice4=Request.form("invoice4")
po4=Request.form("po4")
date4=Request.form("date4")
serial4=Request.form("serial4")
problem4=Request.form("problem4")
terms=Request.form("terms")
delivery=Request.form("delivery")
comments=Request.form("comments")
response.write"Hello World"
sSQL = "INSERT into rmarequest (req_no, date, email, company, contact, phone, fax, address, city, state, zip, part1, qty1, inv1, po1, inv_date1, serial1, problem1, part2, qty2, inv2, po2, inv_date2, serial2, problem2, part3, qty3, inv3, po3, inv_date3, serial3, problem3, part4, qty4, inv4, po4, inv_date4) values('" & MyNewRandomNum & "', '" & thedate & "','" & Email & "','" & Customer & "','" & Contact & "','" & Phone & "', '" & Fax & "', '" & Address & "', '" & City & "', '" & State & "','" & Zip & "', '" & part1 & "', '" & qty1 & "', '" & invoice1 & "', '" & po1 & "', '" & date1 & "', '" & serial1 & "', '" & problem1 & "', '" & part2 & "', '" & qty2 & "', '" & invoice2 & "', '" & po2 & "', '" & date2 & "', '" & serial2 & "', '" & problem2 & "', '" & part3 & "', '" & qty3 & "', '" & invoice3 & "', '" & po3 & "', '" & date3 & "', '" & serial3 & "', '" & problem3 & "', '" & part4 & "', '" & qty4 & "', '" & invoice4 & "', '" & po4 & "', '" & date4 & "')"
stSQL= "INSERT into rmarequest (serial4, problem4, terms, delivery, comments)values( '" & serial4 & "', '" & problem4 & "', '" & terms & "', '" & delivery & "', '" & Comments & "')"
Set conn = server.CreateObject("adodb.recordset")
sConnString="DSN=DSN Name; UID=uid PWD=pwd"
conn.Open(sConnString)
conn.execute(sSQL)
conn.execute(stSQL)
conn.Close
Set conn = Nothing
%>
</body>
</html>
<%>
Again, you cannot enclose numeric data with single quotes. Remove single quotes wherever your data is numeric.
Hello yamaharuss
can you please explain what you said with an example,i am new to asp so i didn't understood what u said.
All of your inserted date is enclosed in a single quote like this
'" & po3 & "'
That's fine if that field it a text or date field but if the field is numeric you need to remove the single quotes like this
" & po3 & "
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks