ASP and Access SQL Problem

M

Micromanaged

I am attempting to insert data into an Access 2k database with the
following in an asp page:

strSQL="INSERT INTO EmpIncentive(Purple, " & _
"Red, Orange, Yellow, Green, Blue, Clndr) " & _
"VALUES('" & rEmployee & "', '" & rdffclt & "', '" & rrspnsetm & "', '"
& rcrrctd & "', '" & rcstmrsrvc & "', '" & rcmmnts & "', '" & rclndr &
"')"


Dim objRS
Set objRS=Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn
objRS.Close
Set objRS=Nothing
objConn.Close
Set objConn=Nothing

When the user hits submit, the data from the form page is posted to a
"Success" page where the above SQL statement is executed. The data is
successfully inserted; however, the html/asp page that is the "Success"
page is supposed to summarize the data for the user gives me the
following error:

Error Type:
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.
/incentive/incentive.asp, line 52

I commented out the objRS.Close line and things work (the line with the
error above. Is this proper?
 
M

Manohar Kamath

There is no details on objConn in the page. Where do you initialize the
variable/create a connection to the database?
 
B

Bob Barrows [MVP]

Micromanaged said:
I am attempting to insert data into an Access 2k database with the
following in an asp page:

strSQL="INSERT INTO EmpIncentive(Purple, " & _
"Red, Orange, Yellow, Green, Blue, Clndr) " & _
"VALUES('" & rEmployee & "', '" & rdffclt & "', '" & rrspnsetm & "',
'" & rcrrctd & "', '" & rcstmrsrvc & "', '" & rcmmnts & "', '" &
rclndr & "')"


Dim objRS
Set objRS=Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn

This is bad. Your query does not return records - why open a recordset???

objConn.Execute strSQL,,129
objRS.Close
Set objRS=Nothing
objConn.Close
Set objConn=Nothing

When the user hits submit, the data from the form page is posted to a
"Success" page where the above SQL statement is executed. The data is
successfully inserted; however, the html/asp page that is the
"Success" page is supposed to summarize the data for the user gives
me the following error:

Error Type:
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.
/incentive/incentive.asp, line 52

I commented out the objRS.Close line and things work (the line with
the error above. Is this proper?
You need to open a recordset using a query that returns records in order for
you to read data from it ...

Bob Barrows
 
S

Stephanie Stowe

Do this. I am assuming that objConn is opened before this code is hit.

strSQL = whatever ...
objConn.Execute strSQL

And do not use the recordset at all. There is no recordset for an INSERT
statement to return anyway.

S
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top