Tutorial Problems

xxdcmast
04-16-2004, 01:19 PM
So I read through the ADO tutorial and did everything that it stated substituting my relevant information into it. I tried running it and I get an error

Compile error: user defined type not defined

it highlights the private sub form_load()

here is my code

Private Sub Form_Load()
Dim MyConn As ADODB.Connection
Dim MyRecSet As ADODB.Recordset
Dim strName As String
Dim strAddress As String


Set MyConn = New ADODB.Connection
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\jad1682\Desktop\New Folder\TISCustomers.mdb;"
MyConn.Open

Set MyRecSet = MyConn.Execute("SELECT Balance, Pin FROM Customers")

Do Until MyRecSet.EOF
strBalance = MyRecSet("Balance")
strPin = MyRecSet("Pin")

lstData.AddItem strBalance & " - " & strPin

MyRecSet.MoveNext
Loop



MyConn.Close

End Sub


This should work correct????

reboot
04-16-2004, 01:54 PM
Did you add a reference to the ADO library? Project->References and select "Microsoft ActiveX Data Objects 2.x Library" ?

LaVolpe
04-16-2004, 01:56 PM
couple things maybe. think the 1st one is the problem.
Did you add a reference to your project for ADODB & not DAO?
Are strBalance & strPin declared anywhere?
Does lstData exist & is it a listbox?
And while you're at it. suggest also
- checking for .RecordCount=0 & not process the Do:Loop if = 0
- .MoveFirst before you enter the loop
- closing your recordset myRecSet.Close
- Erasing your recordset from memory: Set myRecSet=Nothing
- Releasing your connection form memory: Set myconn=Nothing
People will say that these items will be cleared from memory automatically; but don't always count on it & it is good practice to clear things you declare with a NEW statement.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum