Discussion Locked

How to Connect Dbgrid to Sql Recordset

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Can You pls Tell Me How to Connect Dbgrid to SQL servers Recordset using VB6. I cannot Use this in SQL Server but i Can in MSACCESS.

1 reply

by 3wadman

Sub Form_Load()
Dim db As ADODB.Connection
Dim SQL As String

SQL = "Select * from Description order by ServDate DESC;"
Set db = New ADODB.Connection
db.CursorLocation = adUseClient
db.Open strConnect <<<>>>
Set adoPrimaryRS= New ADODB.Recordset
adoPrimaryRS.Open SQL, db, adOpenStatic, adLockOptimistic
Dim otext As TextBox
'Bind the text boxes to the data provider
For Each otext In Me.txtFields
Set otext.DataSource = adoPrimaryRS
Next
Dim oCheck AsCheckBox
'Bind the check boxes to the data provider
For Each oCheck In Me.chkFields
Set oCheck.DataSource = adoPrimaryRS
Next
Set grdDataGrid.DataSource = adoPrimaryRS
End Sub

This discussion is closed to new replies.