|
-
Aug 10th, 2000, 11:17 PM
#1
Thread Starter
Junior Member
Ok, guys...I have a question that is baffling me. I am relatively new to DB programming in VB, and I can't open a recordset. I am hoping that you can tell me why. Here is a brief sample of the code I am using...see any problems?
Dim cnShop As Connection
Dim rsShop As Recordset
Private Sub Form_Load()
Set cnShop = New Connection
cnShop.CursorLocation = adUseClient
cnShop.ConnectionString "Provider=Microsoft.Jet.OLEBD.3.51" & _ "Data Source = My Documents\Shop.mdb"
Set rsShop = New Recordset
rsShop.Open "SELECT * FROM Customers ORDER BY LastName", cnShop, adOpenStatic, adLockOptimistic
End Sub
Now I keep getting a message that says, "The application requested an operation or an object with a reference to a closed or invalid connection object" (The lines of code, of course, are broken up with the "& _" in the proper place, not as they have appeared in this text box, and the data base is located at the Data Source I have specified)
I cannot figure this out...it seems that I have set the connection and the recordset correctly. I have the Microsoft ActiveX Data Objects and Recordsets 2.1 Libraries referenced in the project. Is there some error in this snippet of code? I have tried running the project using this code (although I added an ErrorHandler and a sub procedure that populated a combo box from the recordset, but I keep coming up with the same error? Any advice?
Thanks....
FLL
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|