ASP and Access SQL Problem

Discussion in 'ASP General' started by Micromanaged, Oct 7, 2004.

  1. Micromanaged

    Micromanaged Guest

    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?


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Micromanaged, Oct 7, 2004
    #1
    1. Advertising

  2. 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 (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?
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Manohar Kamath, Oct 7, 2004
    #2
    1. Advertising

  3. 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 (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
    --
    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"
     
    Bob Barrows [MVP], Oct 7, 2004
    #3
  4. 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 (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?
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Stephanie Stowe, Oct 8, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ecoolone
    Replies:
    0
    Views:
    775
    ecoolone
    Jan 3, 2008
  2. cooldv
    Replies:
    3
    Views:
    275
    WIlliam Morris
    Oct 6, 2003
  3. Belinda
    Replies:
    4
    Views:
    368
    Bob Barrows [MVP]
    Jun 11, 2004
  4. Replies:
    10
    Views:
    279
    Bob Barrows [MVP]
    Jan 6, 2005
  5. David
    Replies:
    4
    Views:
    157
    Bob Barrows [MVP]
    Sep 28, 2006
Loading...

Share This Page