Operation is not allowed when the object is closed.

Last post 05-15-2012 9:13 AM by lesk. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 05-11-2012 3:42 PM

    • lesk
    • Not Ranked
    • Joined on 06-02-2006
    • Posts 6

    Operation is not allowed when the object is closed.

    I'm trying to use a vbscript to update and delete fields in a Pervasive 10.3 database. To begin I wanted to see if I can just view data in a table. I can successfully connect, but when I run a simple query on a table it comes up with this error:  NOTE: ddf's and a dsn (Live120) allow me to open the tables in an .mdb. Not sure what I'm doing worng.

    Error: Operation is not allowed when the object is closed.
    Code: 800A0E78
    Source: ADODB.Connection

    My code:

    Set objConnection = CreateObject("ADODB.Connection")
    Set objRecordSet = CreateObject("ADODB.Recordset")
    objConnection.Provider = "Provider=PervasiveOLEDB;Data Source=172.24.2.22;"
    objConnection.ConnectionString = "Driver={Pervasive ODBC Engine Interface};ServerDSN=Live120;UID=strUID;PWD=strPWD;ServerName=Lesk-pc;"
    objRecordset.CursorLocation = adUseClient
    If objConnection.State = adStateOpen Then
     MsgBox "Connected to Live120 on Lesk-pc." (contionusly shows connected)
    Else
     MsgBox "Error connecting to Live120 Lesk-pc."
    End If
    mySQLquerry = "SELECT * FROM " & Chr(34) & "bldg" & Chr(34) also tried "select * from bldg"
    (Fails here with above error) set rstemp = objConnection.Execute(mySQLquerry)
    Do While Not rstemp.EOF
          MsgBox rstemp("bldg_desc")
          rstemp.MoveNext
    Loop
    rstemp.Close
    objConnection.Close

    Any help at all would be appreciated. Thanks les

  • 05-11-2012 4:52 PM In reply to

    Re: Operation is not allowed when the object is closed.

    You need to open the connection before you use it. Before the check of the State, you need a "objConnection.open" line.
  • 05-15-2012 9:13 AM In reply to

    • lesk
    • Not Ranked
    • Joined on 06-02-2006
    • Posts 6

    Re: Operation is not allowed when the object is closed.

    thank you
Page 1 of 1 (3 items)