Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > ASP and Access SQL Problem

Reply
Thread Tools

ASP and Access SQL Problem

 
 
Micromanaged
Guest
Posts: n/a
 
      10-07-2004
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 (0x800A0E7
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?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
 
Manohar Kamath
Guest
Posts: n/a
 
      10-07-2004
There is no details on objConn in the page. Where do you initialize the
variable/create a connection to the database?

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com


"Micromanaged" <> wrote in message
news:...
> 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 (0x800A0E7
> 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?
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      10-07-2004
Micromanaged wrote:
> 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 (0x800A0E7
> 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
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
Stephanie Stowe
Guest
Posts: n/a
 
      10-08-2004
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
"Micromanaged" <> wrote in message
news:...
> 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 (0x800A0E7
> 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?
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Reference, SQL Queries, SQL help ecoolone ASP .Net 0 01-03-2008 10:58 AM
Very annoying error: Access to the path is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity Jay ASP .Net 2 08-20-2007 07:38 PM
Access SQL to ASP SQL not working ... need help please David ASP General 4 09-28-2006 02:23 PM
MS Access SQL > ASP SQL problem.... david@scene-double.co.uk ASP General 10 01-06-2005 12:23 PM
How to read an SQL Server into a ASP page and then change, add, delete and write it back to SQL Server Belinda ASP General 4 06-11-2004 12:16 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57