When I try to run my program on a 56K line I have the following problem:
I have the following delcared as a Public variable:
Set dbconn = New ADODb.Connection
dbconn.ConnectionString=
"provider=microsoft.jet.oledb.4.0;data source=p:\mro\newsystem.mdb;"
dbconn.CursorLocation = adUseClient
dbconn.Open
It takes about 30secs to open the database connection.
I then have the following code in a button on a form.
Dim comtest As ADODb.Command
Dim rstest As ADODb.Recordset
Set comtest = New ADODb.Command
comtest.CommandText = "select contactid from tblcontacts"
comtest.CommandType = adCmdText
comtest.ActiveConnection = dbconn
Set rstest = New ADODb.Recordset
Set rstest.Source = comtest
rstest.CursorType = adOpenStatic
rstest.LockType = adLockReadOnly
rstest.Open
rstest.close
set rstest=nothing
set comtest=nothing
The problem is that the first time when I click the button it takes 40 secs to open the recordset. However, any subsequent times, it just takes 2 secs to open the recordset.
WHY???
The problem is that no matter how many recordsets I open on the form, the first one after the program starts always takes 40 secs. All subsequent ones take 2 secs.
Any suggestions would be very much appreciated.
I have the following delcared as a Public variable:
Set dbconn = New ADODb.Connection
dbconn.ConnectionString=
"provider=microsoft.jet.oledb.4.0;data source=p:\mro\newsystem.mdb;"
dbconn.CursorLocation = adUseClient
dbconn.Open
It takes about 30secs to open the database connection.
I then have the following code in a button on a form.
Dim comtest As ADODb.Command
Dim rstest As ADODb.Recordset
Set comtest = New ADODb.Command
comtest.CommandText = "select contactid from tblcontacts"
comtest.CommandType = adCmdText
comtest.ActiveConnection = dbconn
Set rstest = New ADODb.Recordset
Set rstest.Source = comtest
rstest.CursorType = adOpenStatic
rstest.LockType = adLockReadOnly
rstest.Open
rstest.close
set rstest=nothing
set comtest=nothing
The problem is that the first time when I click the button it takes 40 secs to open the recordset. However, any subsequent times, it just takes 2 secs to open the recordset.
WHY???
The problem is that no matter how many recordsets I open on the form, the first one after the program starts always takes 40 secs. All subsequent ones take 2 secs.
Any suggestions would be very much appreciated.