PDA

Click to See Complete Forum and Search --> : datagrid and msflexgrid


Thai
Jul 17th, 2000, 01:08 PM
Hello I am using ADO connections/recordsets connection to an ms access 97 db. is there a way to set the datagrid or msflexgrid to show the ado recordset without using an ado or dao control?

thanks,
Thai

DrewDog_21
Jul 17th, 2000, 05:41 PM
Set references to Microsoft Access Object Library and Microsoft ActiveX Data Object 2.0 Library, then


Private myCN As ADODB.Connection
Private myRS As New ADODB.Recordset

Private Sub Form_Load()

Set myCN = New ADODB.Connection
With myCN
.ConnectionString = Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=C:\My Documents\myDatabase.mdb
.CursorLocation = adUseClient
.Open
End With

If myRS.State = adStateOpen Then
myRS.Close
End If

myRS.Open "Select * From MyTable Order By MY_FIELD", myCN, adOpenKeyset, adLockOptimistic

Set DataGrid1.DataSource = myRS

End Sub