Results 1 to 6 of 6

Thread: Populating a DB Grid from a RS

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Talking Populating a DB Grid from a RS

    How do I fill a DbGrid with a rs?

  2. #2
    Hyperactive Member PJB's Avatar
    Join Date
    Aug 2000
    Location
    dunno at the moment
    Posts
    302
    are you connecting to your database with a datacontrol or ADO?
    VB6.0 SP4
    Windows 2000
    I'm thinking of a number between

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216
    ado

  4. #4
    Hyperactive Member PJB's Avatar
    Join Date
    Aug 2000
    Location
    dunno at the moment
    Posts
    302
    here's one method:

    Code:
       Dim cn As New ADODB.Connection
       Dim rs As New ADODB.Recordset
    
    Private Sub Form_Load()
     cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source=C:\path\todb.mdb;Jet OLEDB:Database Password=;User ID=;"
        
    With cmd 'set connection and get records
            .ActiveConnection = cn
            .CommandType = adCmdText
            .CommandText = "Select * from tablename"
            .Execute
    End With
    With rs
            .CursorLocation = adUseClient
            .LockType = adLockOptimistic
            .Open cmd
    End With
        Set DataGrid1.DataSource = rs
    End Sub
    there's other methods of course, i had this one open to cut and paste in so it's what i posted

    make sure you set a reference to Microsoft Activex Data objects 2.5 library

    i took the uid and password out obviously
    VB6.0 SP4
    Windows 2000
    I'm thinking of a number between

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Wink

    thank you it works and if ever forget to say thanks it's because I get so wrapped up in what I do I forget.

    Thanks

  6. #6
    Hyperactive Member PJB's Avatar
    Join Date
    Aug 2000
    Location
    dunno at the moment
    Posts
    302
    thanks isn't necessary, it is nice occasionally though
    VB6.0 SP4
    Windows 2000
    I'm thinking of a number between

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