Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LockType / Cursor Type

Status
Not open for further replies.

stnkyminky

Programmer
Oct 15, 2001
476
US
After closing my program, a lock remains on the access database. No connections are remaing and I have unloaded the datareports and dataenvironment. Could the LockType be the culprit? Below are the functions I call to connect and disconnect the database. Thanks

Public Sub ProjectConnect()
Dim connstring As String

connstring = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=J:\Labels\CoolingTower.mdb"
Project_My_Conn.ConnectionString = connstring
Project_My_Conn.ConnectionTimeout = 30
Project_My_Conn.Open

Set Project_rs.ActiveConnection = Project_My_Conn
Project_rs.LockType = adLockOptimistic
Project_rs.CursorType = adOpenStatic

Public Sub ProjectDisconnect()
Project_strSql = ""
Project_rs.Close
Set Project_rs = Nothing
Project_My_Conn.Close
Set Project_My_Conn = Nothing
End Sub Scott
Programmer Analyst
 
Place you disconnect code in the unload event.


By the way you may want to take a look at using ADO



reidfl
 
I am using ADO. Also, I am connecting to the database as needed in the program. I do not want to leave the connection open when I am not using it.

Thanks Scott
Programmer Analyst
 
stnkyminky,

I ran your code and made the following corrections. The code connected and disconnectd from the database and released the lock on the database.

Option Explicit
Dim Project_My_Conn As ADODB.Connection
Dim Project_rs As ADODB.Recordset

Private Sub Form_Load()
ProjectConnect
ProjectDisconnect
End Sub

Public Sub ProjectConnect()
Dim connstring As String
Set Project_My_Conn = New ADODB.Connection
Set Project_rs = New ADODB.Recordset

connstring = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=O:\Humana\MCSC Overpmt\MCSC OverPmt Frontend.mdb"
Project_My_Conn.ConnectionString = connstring
Project_My_Conn.ConnectionTimeout = 30
Project_My_Conn.Open

Set Project_rs.ActiveConnection = Project_My_Conn
Project_rs.LockType = adLockOptimistic
Project_rs.CursorType = adOpenStatic
End Sub

Public Sub ProjectDisconnect()
' Project_strSql = ""
' Project_rs.Close
Set Project_rs = Nothing
Project_My_Conn.Close
Set Project_My_Conn = Nothing
End Sub

reidfl
 

After some testing I found that when I ran the program from my computer (Admin level) the lock was released. When I ran the program from the client machine, the lock wasn't released. I suspect this may be a permissions issue.

Reidfl,
I do appreciate your help and I will try your solution.

Thanks again. Scott
Programmer Analyst
 
Reidfl,

what OS are you running? Scott
Programmer Analyst
 
Running Win2k


reidfl "Keep Your Code Tight"
 
Thats what I thought. Im running W2K too and my locks are disappearing but the problem is occuring on an NT machine. Scott
Programmer Analyst
 
Hello Stnkyminky and others.

Apologies for bringing back up an old thread.

Was there ever a resolution to this problem? I'm experiencing similar problems on a number of Win2k, sp3 machines running an Access 2000 database.

All the best,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top