|
 |
access thread: Opening an ADO recordset question
Message #1 by "Carl Schwarcz" <carl@s...> on Sat, 9 Jun 2001 13:06:43 -0700
|
|
I've made two different ways of opening an ADODB record set which I
thought were equivalent. However the first generates the following
run-tim error:
Run-time error '-2147467259(80004005)
The database has been placed in a state by user "Admin'
on machine 'CARL' that prevents it from being opened or locked.
(By the way I am the ADMIN user and have the database open as
this code gets invoked from)
Here's the code which generates the error:
Dim cnn As ADODB.Connection
Dim recset As ADODB.Recordset
Set cnn = New ADODB.Connection
Set recset = New ADODB.Recordset
' open connection and then use it
cnn.Open CurrentProject.Connection
recset.Open "Select * From tblCompany", cnn
However, the following code works fine. What am I missing?
Dim recset As ADODB.Recordset
Set recset = New ADODB.Recordset
' just use Current Project
recset.Open "Select * From tblCompany",
CurrentProject.Connection
Any pointers would be appreciated...
Message #2 by "Jonathan Smith1" <jts_2k@h...> on Mon, 18 Jun 2001 13:18:50
|
|
With the first method you could try Dimming the connection and recordset
with a new method IE
Dim cnn As New ADODB.Connection
Dim recset As New ADODB.Recordset
This should initialise these as new connections and recordsets
If not u might not be able to define the connection process unless you
speify the usual connections needed.
J
> I've made two different ways of opening an ADODB record set which I
> thought were equivalent. However the first generates the following
> run-tim error:
> Run-time error '-2147467259(80004005)
> The database has been placed in a state by user "Admin'
> on machine 'CARL' that prevents it from being opened or locked.
>
> (By the way I am the ADMIN user and have the database open as
> this code gets invoked from)
>
> Here's the code which generates the error:
> Dim cnn As ADODB.Connection
> Dim recset As ADODB.Recordset
>
> Set cnn = New ADODB.Connection
> Set recset = New ADODB.Recordset
>
> ' open connection and then use it
> cnn.Open CurrentProject.Connection
> recset.Open "Select * From tblCompany", cnn
>
> However, the following code works fine. What am I missing?
>
> Dim recset As ADODB.Recordset
>
> Set recset = New ADODB.Recordset
>
> ' just use Current Project
> recset.Open "Select * From tblCompany",
> CurrentProject.Connection
>
>
> Any pointers would be appreciated...
>
|
|
 |