Hi
I have used this class system before without a problem and I keep looking at it and cannot see my error but I get Unknown ADODB error ADO
could you please tell me what I have done wrong please
I have used this class system before without a problem and I keep looking at it and cannot see my error but I get Unknown ADODB error ADO
could you please tell me what I have done wrong please
Code:
VB6
Option Explicit
'clsTitles - wraps up Table. By keeping the
'interface consistent it should be possible to move the class
'to a point at some other data source, such as RDO ResultTest,
'on a flat file, without the users of the class ever noticing.
Public Event DataChange()
'Public members to implement properties
'for Titles DB
Public strName As String
Public strNum1 As String
Public strNum2 As String
Public strNum3 As String
'Public connection to Database
'and the recordset
Public strConn As New ADODB.Connection 'My Connection
Public myRs As New ADODB.Recordset 'My Recordset
Public strSQL As String 'My Command
Public Sub Class_Initialize()
'When an instance of the class is created, we want to
'connect to the Database and open up the Database Table.
'Set,describe,and open the connection to the database
'ReDim strMNum(1 To 2)
'ReDim strWNum(1 To 2)
'***************Declaration*************
Set frmTest.dgControl.DataSource = Nothing
'***************Connection**************
dbPath = "E:\Program Files\Microsoft Visual Studio\VB98\Ron Files\Class Example"
Set strConn = New ADODB.Connection
strConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPath & "\Telephone.mdb"
strConn.CursorLocation = adUseClient
' Debug.Print App.Path
' Set and Define Command
strSQL = "SELECT * FROM Names ORDER BY LastName"
' Set and Define Recordset
With frmTest
.adoControl.ConnectionString = strConn
.adoControl.RecordSource = strSQL
Set .dgControl.DataSource = .adoControl
Debug.Print dbPath
Debug.Print strSQL
Debug.Print strConn
End With
Set Me.myRs = New ADODB.Recordset
With Me.myRs
Set .ActiveConnection = strConn
.CursorType = adOpenStatic
.Source = strSQL
' .Open
End With
' Add columns to the Recordset
With frmTest.dgControl
.Columns.Add 2
strName = VBA.vbNullString & .Columns(0)
strNum1 = VBA.vbNullString & .Columns(1)
strNum2 = VBA.vbNullString & .Columns(2)
' strNum3 = VBA.vbNullString & .Columns(3)
End With
'*********************************************
'Clean up after you have finished
myRs.Close
Set myRs = Nothing
strConn.Close
Set strConn = Nothing
End Sub