problem with adodb recordset opening - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

problem with adodb recordset opening

kapiloo7kapiloo7 Posts: 45Member
hii friends,
I have a ADODB.Connection object and different ADODB.Recordset objects.
First recordset is opened succesesfully but while opening second recordset it gives error
"Method 'Open' of object '_Recordset' failed".
i tried it with command object also. At that time i got message
"Method 'Execute' of object '_Command' failed".

can any body plz help me?

Comments

  • GideonOmegaGideonOmega Posts: 617Member
    : hii friends,
    : I have a ADODB.Connection object and different ADODB.Recordset objects.
    : First recordset is opened succesesfully but while opening second recordset it gives error
    : "Method 'Open' of object '_Recordset' failed".
    : i tried it with command object also. At that time i got message
    : "Method 'Execute' of object '_Command' failed".
    :
    : can any body plz help me?
    :


    Could you post the code you are using for the connection object and both recordsets for us to have a look at?
    [blue]
    C:Dos
    C:Dos Run
    Run Dos Run
    [/blue]

  • kapiloo7kapiloo7 Posts: 45Member
    /*** i am using a class module ***/

    option explicit
    dim Con as adodb.connection
    dim rsTemp as adodb.recordset


    /*I have a procedure*/
    public sub Loaddesign(sDname as string)

    set con = new adodb.connection
    con.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
    App.Path & "Data.mdb"

    /* in this procedure i am opening a recordset*/
    set rstemp = new adodb.recordset
    rstemp.open "Select * from R1 where Dname=' " & sDname & " ' ", con, adOpenStatic, adLockReadOnly
    -----
    -----
    -----
    /* then after opening this recordset successfully i am opening another recordset rs1 */
    call LaodSection( rstemp("Rname"))

    end sub


    private sub LoadSection(sRName as string)
    dim rec as adodb.recordset

    rec.open "select * from sections where Rname = ' " & sRName & " ' ", con ,adOpenStatic, adLockReadOnly
    /**** at this line it gives error msg "Method 'Open' of object '_Recordset' failed."***/

    end sub
  • btsebbtseb Posts: 67Member
    : /*** i am using a class module ***/
    :
    : option explicit
    : dim Con as adodb.connection
    : dim rsTemp as adodb.recordset
    :
    :
    : /*I have a procedure*/
    : public sub Loaddesign(sDname as string)
    :
    : set con = new adodb.connection
    : con.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
    : App.Path & "Data.mdb"
    :
    : /* in this procedure i am opening a recordset*/
    : set rstemp = new adodb.recordset
    : rstemp.open "Select * from R1 where Dname=' " & sDname & " ' ", con, adOpenStatic, adLockReadOnly
    : -----
    : -----
    : -----
    : /* then after opening this recordset successfully i am opening another recordset rs1 */
    : call LaodSection( rstemp("Rname"))
    :
    : end sub
    :
    :
    : private sub LoadSection(sRName as string)
    : dim rec as adodb.recordset
    :
    : rec.open "select * from sections where Rname = ' " & sRName & " ' ", con ,adOpenStatic, adLockReadOnly
    : /**** at this line it gives error msg "Method 'Open' of object '_Recordset' failed."***/
    :
    : end sub
    :
    [blue]You might try two things:
    1.) Close your connection prior to trying to reopen it (It was opened in the previous recordset)
    2.) you need to set rec to a new instance of the recordset[/blue]
    [code] set rec = New ADODB.Recordset[/code]
  • kapiloo7kapiloo7 Posts: 45Member
    : [blue]You might try two things:
    : 1.) Close your connection prior to trying to reopen it (It was opened in the previous recordset)
    : 2.) you need to set rec to a new instance of the recordset[/blue]
    : [code] set rec = New ADODB.Recordset[/code]
    :

    i have changed my code like this
    [code]
    option explicit
    dim Con as adodb.connection
    dim rsTemp as adodb.recordset
    [/code]

    I have a procedure
    [code]
    public sub Loaddesign(sDname as string)
    call OpenConnection
    set rstemp = new adodb.recordset
    rstemp.open "Select * from R1 where Dname=' " & sDname & " ' ", con, adOpenStatic, adLockReadOnly
    -----
    -----
    -----
    call LaodSection( rstemp("Rname"))
    end sub

    private sub LoadSection(sRName as string)
    dim rec as adodb.recordset

    set rec = new adodb.recordset
    call OpenConnection

    rec.open "select * from sections where Rname = ' " & sRName & " ' ", con ,adOpenStatic, adLockReadOnly
    end sub
    [/code]

    at this procedure it gives error msg "Method 'Open' of object '_Recordset' failed."

    now i have added this procedure for opening connection at various point

    [code]
    private sub OpenConneciton()

    set con = new adodb.connection
    if con.state = 1 then con.close
    con.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
    App.Path & "Data.mdb"

    end sub
    [/code]
Sign In or Register to comment.