Click to See Complete Forum and Search --> : Populating MSHFlexGrid with Recordset
Clunietp
Jan 9th, 2000, 12:13 AM
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
LG
Jan 9th, 2000, 12:41 AM
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
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
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.