CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2001
    Posts
    1

    problem opening ado recordsets

    Hi...
    I'm trying to return a recordset using ado 2.6. I wrote this code using ODBC driver for db2, however I had to switch it to SQLOLEDB. Everything works fine, except when I call certain stored procedures using recordset.open(). When it doesn't work, the open call returns, yet the recordset is still not open. The only common thread I can find doesn't seem to make any sense: procedures that take more than one argument and return recordsets are having the problem.
    Here is an abridged version of my code:
    Dim rs As ADODB.Recordset, con As ADODB.Connection
    Set rs = New ADODB.Recordset

    Set con = New ADODB.Connection

    con.ConnectionString = "Provider=SQLOLEDB;Data Source=xxx.xxx.xxx.xxx:1433;Initial Catalog=dbname; User ID=****;Password=****;network=dbmssocn;address=xxx.xxx.xxx.xxx:1433"

    con.open

    rs.CursorLocation = adUseClient
    Call rs.Open("ps_adv 1,2,3", con, adOpenForwardOnly, adLockBatchOptimistic, adCmdText)
    Set rs.ActiveConnection = Nothing

    Thanks for any help.
    -Ari



  2. #2
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: problem opening ado recordsets

    You really should be using Command objects for stored procs with parameters. it really helps out in situations like this.

    Also, if a stored proc doesn't return any data, the resulting recordset object will not be open and EOF, but rather still Closed. the command object, unfortunately, does not alleviate this problem. so be sure to check for ((rs.State And adStateOpen) = adStateOpen) before moving through the recordset.

    just some thoughts,

    john

    John Pirkey
    MCSD
    http://www.ShallowWaterSystems.com
    http://www.stlvbug.org
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured