Best way is to use Component One's XArrayDB, and bind the grid to it.
You'll need to include a Project, Reference to ComponentOne XArrayDB Object.
In your code, load the XArrayDB, then bind the TDBGrid to it. This example
puts each row's fields into module-level variants (good practice for loading
data into an XArrayDB), then loads each field into the XArrayDB:
' variants for loading XArrayDB
Private mvDescription As Variant
Private mvEffectiveDate As Variant
Private mvLastUpdatedAt As Variant
' XArrayDB (will be bound to TDBGrid)
Private mXArrayDB As New XArrayDB
' XArrayDB constants
Private Const INITIAL_ARRAY_LBOUND As Integer = 0
Private Const INITIAL_ARRAY_UBOUND As Integer = -1
' XArrayDB column constants
Private Const XA_DESCRIPTION As Integer = 0
Private Const XA_EFFECTIVE_DATE As Integer = 1
Private Const XA_LAST_UPDATED_AT As Integer = 2
Private Const XA_FIRST_COL As Integer = XA_DESCRIPTION
Private Const XA_LAST_COL As Integer = XA_LAST_UPDATED_AT
'...then after the recordset is loaded:
Dim i As Integer
With adoObject
i = 0
.MoveFirst
While Not .EOF
mvDescription = !Description
mvEffectiveDate = !EffectiveDate
mvLastUpdatedAt = !LastUpdatedAt
mXArrayDB.ReDim INITIAL_ARRAY_LBOUND, i, XA_FIRST_COL,
XA_LAST_COL
mXArrayDB(i, XA_DESCRIPTION) = mvDescription
mXArrayDB(i, XA_EFFECTIVE_DATE) = mvEffectiveDate
mXArrayDB(i, XA_LAST_UPDATED_AT) = mvLastUpdatedAt
.MoveNext
i = i + 1
Wend
End With
' rebind TDBGrid to XArrayDB (to refresh TDBGrid display)
With TDBGrid1
.Array = mXArrayDB
.Bookmark = Null
.ReBind
End With
DoEvents
The above code has not been tested.
HTH, Pete
-----Original Message-----
From: th3wav3@y... [mailto:th3wav3@y...]
Sent: Wednesday, July 24, 2002 5:53 AM
To: professional vb
Subject: [pro_vb] Populate Component One true DB grid using
ADODB.Recordset
need help here,
can anyone give me code to populate truedbgrid using adodb.recordset using
storage as data mode.
thankz
---
Visual C# - A Guide for VB6 Developers
This book will make it easy to transfer your skills
from Visual Basic 6 to C#, the language of choice
of the .NET Framework.
http://www.wrox.com/ACON11.asp?ISBN=1861007175&p2p0059