- Joined
- Sep 9, 2002
- Messages
- 5,657
Man, there are just no good douments on this stuff anywhere. I'm going to have to go and buy a book. I've worked with some ADO code here at work, once the other guys got it started (since departed so I can't ask) with no troubles but it seems I can never get started though!!
look how stupid I am! I just have a form with a button to open and close the recordset... and I can't do it!
_______________________
Option Compare Database
Option Explicit
Dim CurConn As ADODB.Connection
Dim rstContacts As New ADODB.Recordset
Dim CurDB As Database
Public Sub cmdClose_Click()
rstContacts.Close
End Sub
Public Sub cmdOpen_Click()
Set CurDB = CurrentDb
Set CurConn = New ADODB.Connection
With CurConn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "data source= " + CStr(CurDB.Name)
.Open
End With
Set rstContacts = New ADODB.Recordset
rstContacts.Open "Select * FROM Contacts", CurConn, adOpenDynamic, adLockOptimistic, adCmdText
End Sub
_________________________________-
Why am I so f'ing retarded? I get an error when trying to open this connection, not to the recordset yet, just the damn connection(CurConn.Open)....
Run-time error '-2147467259 (80004005)':
Could not use "; file already in use.
This is really annoying. I've gone through examples in VB6 where I can connect to SQL server and run ADO but I can never set the conection up on my own, for different apps. Books on the topic are annoying as well often not mentioning what references you should have hooked in. I've tried closing the connection to make sure it's not floating about with the immediate window... after all program bombs as soon as I hit open, so I can't hit close. Help!!
look how stupid I am! I just have a form with a button to open and close the recordset... and I can't do it!
_______________________
Option Compare Database
Option Explicit
Dim CurConn As ADODB.Connection
Dim rstContacts As New ADODB.Recordset
Dim CurDB As Database
Public Sub cmdClose_Click()
rstContacts.Close
End Sub
Public Sub cmdOpen_Click()
Set CurDB = CurrentDb
Set CurConn = New ADODB.Connection
With CurConn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "data source= " + CStr(CurDB.Name)
.Open
End With
Set rstContacts = New ADODB.Recordset
rstContacts.Open "Select * FROM Contacts", CurConn, adOpenDynamic, adLockOptimistic, adCmdText
End Sub
_________________________________-
Why am I so f'ing retarded? I get an error when trying to open this connection, not to the recordset yet, just the damn connection(CurConn.Open)....
Run-time error '-2147467259 (80004005)':
Could not use "; file already in use.
This is really annoying. I've gone through examples in VB6 where I can connect to SQL server and run ADO but I can never set the conection up on my own, for different apps. Books on the topic are annoying as well often not mentioning what references you should have hooked in. I've tried closing the connection to make sure it's not floating about with the immediate window... after all program bombs as soon as I hit open, so I can't hit close. Help!!