Results 1 to 3 of 3

Thread: Populating MSHFlexGrid with Recordset

  1. #1

    Thread Starter
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    Flexgrid can only be bound to a data source (data controls, etc) and does not appear to allow to be bound to an ADO recordset at run time.

    If you just want to use only the ado objects, you could manually add the rows to the grid after opening your recordset.

    I suppose you could also add a ADO data control to your form, bind the grid to it, and then obtain the recordset at runtime and then refresh the grid.....

    Tom

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308

    Post

    Hi, Albert.

    Serge gave this code, but for some reason I couldn't find link to it.

    Dim cn as New ADODB.Connection
    Dim rs as New ADODB.Recordset
    Dim i as Integer
    Dim lRow as Long

    cn.Provider="Microsoft.Jet.OLEDB.3.51"
    cn.Open "c:\Program Files\Microsoft Visual Studio\vb98\Nwind.mdb","admin",""
    rs.Open "Select * From Customers", cn, adOpenStatic
    lRow=1
    If rs.EOF And rs.BOF Then Exit Sub

    MSFlexGrid1.Cols = rs.Fields.Count
    MSFlexGrid1.Rows = rs.RecordCount + 1

    Do Until rs.EOF
    For i = 0 To rs.Fields.Count - 1
    MSFlexGrid1.TextMatrix(0, i)= rs(i).Name
    MSFlexGrid1.TextMatrix(lRow, i)= "" & rs(i).Value
    Next
    lRow = lRow + 1
    rs.MoveNext
    Loop



  3. #3
    Guest

    Post


    Hi,
    I am trying to program a recordset to populate MSHFlexGrid control with Data records from a table. I have created a connectionstring to connect to "NWind" database and also set an ADO reference in code. Please not, I do not want to use the DataEnvironment tool neither the ADO Data control components. Any help would be much appreciated. Thank you

    Albert

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