954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Unable to insert data into database.

Hi guys, i hope u can help me solve this prob of mine. Im currently werking on this project and somehow im unable to insert this data into my database eventhough the data was being retrieved. Can anione help :sad:


<% option explicit %>
<% response.buffer = true %>

<%



Dim conn, recaffected, sql, qty, increment, updated, objRS, objRS2, name, productid

qty=1

increment=0
updated=0

set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("dbProduct.mdb"))

set objRS = Server.CreateObject("ADODB.recordset")
set objRS2 = Server.CreateObject("ADODB.recordset")

objRS.Open "SELECT * FROM OrderTable WHERE shopperid=" & session("shopperid")" , conn
objRS2.Open "SELECT * FROM Product WHERE productid=" & request.querystring("productid"), conn


sql="INSERT INTO OrderTable(shopperid, productid, qty, increment, updated, pdt, startbid1)"
sql=sql & " VALUES "
sql=sql & "(" & session("shopperid") & ", "
sql=sql & objRS2("productid") & ", "
sql=sql & qty & ", "
sql=sql & increment & ", "
sql=sql & updated & ", "
sql=sql & objRS2("name") & ", "
sql=sql & objRS2("startbid") & ") "

on error resume next
response.Write(sql)
response.end
conn.Execute sql, recaffected
if err<>0 then
response.write("
Product is already included, try again.")
else
response.redirect("buy2.asp")
end if


objRS.close
objRS2.close

conn.close

%>


Is it bcos of the session??

screwrup
Newbie Poster
2 posts since Feb 2006
Reputation Points: 10
Solved Threads: 0
 

well to start off with, you are passing recaffected as a parameter to conn.execute, but you never set it to any value

campkev
Posting Pro in Training
484 posts since Jul 2005
Reputation Points: 14
Solved Threads: 19
 

ok dude.. . email me.. .lets fix this... i understand your problem but i really dont wanna type out the code

conspiringfate
Newbie Poster
22 posts since Feb 2006
Reputation Points: 10
Solved Threads: 1
 
ok dude.. . email me.. .lets fix this... i understand your problem but i really dont wanna type out the code

Why not help her solve the problem here? If so then everyone else will have the opportunity to see the solution and learn something...

DanceInstructor
Posting Whiz
368 posts since Feb 2005
Reputation Points: 17
Solved Threads: 14
 

I'm a SHE aniwae.. :)

screwrup
Newbie Poster
2 posts since Feb 2006
Reputation Points: 10
Solved Threads: 0
 

waits for email! lol

conspiringfate
Newbie Poster
22 posts since Feb 2006
Reputation Points: 10
Solved Threads: 1
 
waits for email! lol

Please read our posting rules regarding requesting and/or offering help via any channels other than the forums. In accordance with those rules, please refrain from offering such assistance here in the future.

Thanks in advance for understanding.

DMR
Wombat At Large
Team Colleague
7,229 posts since Dec 2003
Reputation Points: 221
Solved Threads: 370
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You