Dim con As ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Class_Initialize()
Set con = New ADODB.Connection
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\san\My Documents\db1.mdb;Persist Security Info=False"
con.CursorLocation = adUseClient
con.Open
End Sub
Public Function GetData(SQLStr As String) As Object
rs.Open SQLStr, con
Set GetData = rs
End Function
Code (VB)
Private Sub Form_Load()
Dim t As New Test
Set DataGrid1.DataSource = t.GetData("Select * from table1")
End Sub