Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    14

    Unanswered: vb recordset from access

    Can anybody see a problem with this code.
    I can't get any records returned into the rs object with the SELECT statement, I can get the UPDATE statement to work. I installed VB6 after VS.NET , could this cause a problem for me? I get the same problem with a Sybase and MS SQL databases.

    connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\testing\Desktop\db1.mdb;Persist Security Info=False"

    Dim cn As New ADODB.Connection
    cn.ConnectionString = connectionString

    Dim rs As New ADODB.Recordset
    cn.Open
    Set rs = cn.Execute("SELECT * FROM OrderTbl")

    Debug.Print rs.RecordCount
    'this returns -1 and it should be greater than 0

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    This is expected behavior if you permit asynchronous row retrieval (the default). You can force all of the rows to be retrieved by navigating to the last row which will set RecordCount to the correct value.

    -PatP

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54

    Re: vb recordset from access

    Originally posted via PM by coldfire
    What properties of the recordset sould I set to force all the records to be automatically retreived.

    When I do a rs.movelast it won't allow fetching backwards. I set the rs.CursorType = adOpenDynamic.
    According to the MSDN documentation for RecordCount, you need to set the recordset cursor type to ADOpenStatic.

    -PatP

Posting Permissions

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