Results 1 to 2 of 2

Thread: Linking SQL recordset to DataGrid in DAO 3.51

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 1999
    Location
    Houston
    Posts
    48

    Post

    Installed MS VB 6.0 recently and my apps containing DBGrids had the "rug put out from under them." Specifically, DBGrids were disabled when opening projects, only OLEDB Datagrid shows on project Components.

    At any rate, I can successfully link a table to a new Datagrid using both DAO 3.51 and OLEDB thru ADODC1. However, in the code below
    --------------------------------
    Dim history1 As Database
    Dim qry As String
    Dim Mysnap1 As Recordset
    ChDir App.Path
    Set history1 = Workspaces(0).OpenDatabase("pedigree.mdb", False, False, ";pwd=genetics;")
    qry = "SELECT * FROM Patients Order by [idnumber] ASC"
    Set Mysnap1 = history1.OpenRecordset(qry, dbOpenDynaset)
    Set Data1.Recordset = Mysnap1

    --------------------------------------
    I can't replace the command:

    Data1.Recordset = Mysnap1

    with

    ADODC1.Recordset = Mysnap1

    any way without getting an error. ADODC1 does have a recordset property, but I can't use it without an error. This prevents me from linking the sorted snapshot with Datagrid through ADODC1.

    How can I connect the sorted snapshot (Mysnap1) to a Datagrid with ADODC1?

    -LP

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Recordset is an object, and you have to assign to this object using Set keyword.

    Code:
        Dim cn As New ADODB.Connection
        Dim rs As New ADODB.Recordset
        
        cn.Provider = "Microsoft.Jet.OLEDB.3.51"
        cn.Open "D:\Microsoft Visual Studio\VB98\Nwind.mdb", "admin", ""
        
        rs.Open "Select * from customers", cn, adOpenStatic
        
        Set Adodc1.Recordset = rs
    Good luck and best regards,

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]



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