ASP and Access SQL Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Micromanaged

    ASP and Access SQL Problem

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

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


    Dim objRS
    Set objRS=Server.Cr eateObject("ADO DB.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

    #2
    Re: ASP and Access SQL Problem

    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



    "Micromanag ed" <novirus@nospam .org> wrote in message
    news:eGcMxeLrEH A.644@tk2msftng p13.phx.gbl...[color=blue]
    > I am attempting to insert data into an Access 2k database with the
    > following in an asp page:
    >
    > strSQL="INSERT INTO EmpIncentive(Pu rple, " & _
    > "Red, Orange, Yellow, Green, Blue, Clndr) " & _
    > "VALUES('" & rEmployee & "', '" & rdffclt & "', '" & rrspnsetm & "', '"
    > & rcrrctd & "', '" & rcstmrsrvc & "', '" & rcmmnts & "', '" & rclndr &
    > "')"
    >
    >
    > Dim objRS
    > Set objRS=Server.Cr eateObject("ADO DB.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![/color]


    Comment

    • Bob Barrows [MVP]

      #3
      Re: ASP and Access SQL Problem

      Micromanaged wrote:[color=blue]
      > I am attempting to insert data into an Access 2k database with the
      > following in an asp page:
      >
      > strSQL="INSERT INTO EmpIncentive(Pu rple, " & _
      > "Red, Orange, Yellow, Green, Blue, Clndr) " & _
      > "VALUES('" & rEmployee & "', '" & rdffclt & "', '" & rrspnsetm & "',
      > '" & rcrrctd & "', '" & rcstmrsrvc & "', '" & rcmmnts & "', '" &
      > rclndr & "')"
      >
      >
      > Dim objRS
      > Set objRS=Server.Cr eateObject("ADO DB.Recordset")
      > objRS.Open strSQL, objConn[/color]

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

      objConn.Execute strSQL,,129
      [color=blue]
      > 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?
      >
      >[/color]
      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"


      Comment

      • Stephanie Stowe

        #4
        Re: ASP and Access SQL Problem

        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
        "Micromanag ed" <novirus@nospam .org> wrote in message
        news:eGcMxeLrEH A.644@tk2msftng p13.phx.gbl...[color=blue]
        > I am attempting to insert data into an Access 2k database with the
        > following in an asp page:
        >
        > strSQL="INSERT INTO EmpIncentive(Pu rple, " & _
        > "Red, Orange, Yellow, Green, Blue, Clndr) " & _
        > "VALUES('" & rEmployee & "', '" & rdffclt & "', '" & rrspnsetm & "', '"
        > & rcrrctd & "', '" & rcstmrsrvc & "', '" & rcmmnts & "', '" & rclndr &
        > "')"
        >
        >
        > Dim objRS
        > Set objRS=Server.Cr eateObject("ADO DB.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![/color]


        Comment

        Working...