Error in connection string

n3wguys

Registered User.
Local time
Today, 09:11
Joined
May 14, 2012
Messages
39
Dear Friend..

I faced this error :




Run-time error '-2147467259(80004005)

The database has been placed in a state by user 'Admin' on machine
"topleveldomain' that prevents it from being opened or locked.




in vba code :
I write such as :


con.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\My Project\BE\database1.accdb;"



I have used the ms access 2013.

I also have split this database such as instruction by people but nothing effect.:banghead:

can you help me, please?

thanks so much that your help
 
The error is because you are trying to open the database that is already open? What exactly are you trying to achieve here?
 
thanks your reply

honestly, I added this script on form_load.


this code :

Sub runFormAll()
Dim con As ADODB.Connection
Dim recSet As ADODB.Recordset
Dim strFrmNm As String
Dim strcon As String


Set recSet = New ADODB.Recordset
recSet.CursorType = adOpenKeyset
recSet.LockType = adLockOptimistic
recSet.CursorLocation = adUseClient

strcon = CurrentProject.Path & "\database1.accdb;"
Set con = New ADODB.Connection
'con.Open "Microsoft.ACE.OLEDB.12.0;Data Source=& CurrentProject.Path & \database1.accdb;" 'OpenExclusive:=False;info security=false"
With con
.Provider = "Microsoft.ACE.OLEDB.12.0;"
.Mode = adModeReadWrite
.ConnectionString = "data source=" & strcon
.Open
End With
If conn.State = adStateOpen Then
MsgBox "Connection was opened."
End If
recSet.Open "SELECT * FROM employees", con

strFrmNm = "frmemployees"

DoCmd.OpenForm strFrmNm
Set Application.Forms(strFrmNm).Recordset = recSet

recSet.Close
con.Close
Set recSet = Nothing
Set con = Nothing
End Sub


Private Sub Form_Load()
runFormAll
End Sub


-------------

I want to load all data to object such as txtbox..
but i dont know why this error show?
 
Is database1 the database you have open and are trying to run code in?
If so then you don't need to re-open it. All you need is to set the recordset with teh current database as below:

CurrentDb.OpenRecordset "SELECT * FROM employees"
 

Users who are viewing this thread

Back
Top Bottom