...

View Full Version : help please.... please



lovesirius12
08-17-2005, 05:17 AM
can you tell what might be the problem here?
the error is - ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.
ctr and cnt are variables, cone is my adodb.connection

for ctr = 0 to cnt
set vanny=server.createobject("adodb.recordset")
p = prod(ctr)
q = quan(ctr)
c = cost(ctr)

sql = "insert into orderinvent (clientcode, product, quantity, dateorder, price) values (" & code & ",'" & p & "','" & q & "'," & md & "," & c & ")"
vanny.open sql, cone
vanny.close
set vanny = nothing
Next

Spudhead
08-17-2005, 01:34 PM
Umm. Why are you using a recordset to do an insert? It's unnecessary.

Your error is probably because the connection isn't open.



set myConnection = server.createobject("ADODB.Connection")
myConnection.open myConnectionStringOrDSN

for ctr = 0 to cnt
p = prod(ctr)
q = quan(ctr)
c = cost(ctr)
intRowsAffected = 0

sql = "insert into orderinvent (clientcode, product, quantity, dateorder, price) values (" & code & ",'" & p & "','" & q & "'," & md & "," & c & ")"
myConnection.execute sql, intRowsAffected
if intRowsAffected then
'SQL executed successfully
else
'SQL failed
end if
Next

myConnection.close
set myConnection = nothing

miranda
08-17-2005, 03:38 PM
for ctr = 0 to cnt
p = prod(ctr)
q = quan(ctr)
c = cost(ctr)

cone.execute("insert into orderinvent (clientcode, product, quantity, dateorder, price) values (" & code & ",'" & p & "','" & q & "'," & md & "," & c & ")")
Next
cone.close
set cone = nothing


however wouldn't your database column quantity have a datatype of number? in which case you would not have the single quotes around the q

for ctr = 0 to cnt
p = prod(ctr)
q = quan(ctr)
c = cost(ctr)

cone.execute("insert into orderinvent (clientcode, product, quantity, dateorder, price) values (" & code & ",'" & p & "'," & q & "," & md & "," & c & ")")
Next
cone.close
set cone = nothing



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum