Sign in to follow this  
Followers 0
A. martinod

ACCESS DATABASE LOCKED

6 posts in this topic

#1 ·  Posted (edited)

After I create a connection to an Access Database :

$objconn =objCreate("ADODB.Connection")

if @error Then

MsgBox(4096,"","Cannot create Connection")

endif

$objconn.Provider="Microsoft.Jet.OLEDB.4.0"

$objconn.Open ("C:\db1.mdb")

others programms cannot share anymore the database.

Is there a solution to share it ?

Regards,

AL,

Edited by A. martinod

Share this post


Link to post
Share on other sites



It is just my intuition working, but this might help even though it takes longer:

$objconn =objCreate("ADODB.Connection")
if @error Then
MsgBox(4096,"","Cannot create Connection")
endif
Sleep(10000)
$objconn.Provider="Microsoft.Jet.OLEDB.4.0"
Sleep(10000)
$objconn.Open ("C:\db1.mdb")

Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

others programms cannot share anymore the database.

When an application accesses a database, it is locked so that the data would not get corrupted. Eg: 2 apps write to the same database.

#)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

My intuition was wrong and logic has it instead Technodude's idea is correct. If you are using a machine in an office network of computers many of which use some program like Microsoft Access to access the same database, all those computers can seem to read and even alter the same database file at the same time. Programmatically though, what might actually be happening is that on each of those computers there is loaded into memory a complete copy of the database, and each time it is altered on a computer, some program (perhaps Access itself) gets in a queue waiting for its turn to modify the original copy of the database file while those higher in the queue get their chance. Your program might have to try to mimic that behavior of networked Access. If you are not on a network try to find some way in your code to finish your business with the database and then close the database file before other programs need it:

$objconn.Close ("C:\db1.mdb"). :D

Edited by Squirrely1

Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

My intuition was wrong and logic has it instead Technodude's idea is correct. You are probably on a office network of computers many of which use Microsoft Access and all those computers can read and even alter the same database file seemingly. Programmatically though, what might actually be happening is that on each of those computer there is loaded into memory a complete copy of the database, and each time it is altered on a computer, the alteration modifies the original copy of the database by some program (perhaps Access itself), enabling the sort of network-wide accessibility to the same database file. Your program might have to try to mimic that behavior of Access. :D

You can't access a database without a dsn except if you use a dsnless connection.

Try this one wich allows copying a tabe from a databse to another one but the way to connect to a database with dsnless connection is the same

Const $adOpenStatic = 3
Const $adLockOptimistic = 3
$dsn= "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & @scriptdir & "\db1.mdb"
$adoCon = ObjCreate ("ADODB.Connection")
$adoCon.Open ($DSN)
$adoRs = ObjCreate ("ADODB.Recordset")
;You must Clear Operation Table in Destination mdb if not an error happen
$adoSQL = "SELECT * INTO Operation IN " & "'" & "CPTSTE.mdb" & "'" & " FROM Operation;"
$adocon.Open(  $adosql , $adors,$adOpenStatic, $adLockOptimistic)
$adoRs=""
$adocon.close
$adoCon=""

See always randallc post which treat of the same things with anoyther way

Share this post


Link to post
Share on other sites

You can't access a database without a dsn except if you use a dsnless connection.

Try this one wich allows copying a tabe from a databse to another one but the way to connect to a database with dsnless connection is the same

Const $adOpenStatic = 3
Const $adLockOptimistic = 3
$dsn= "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & @scriptdir & "\db1.mdb"
$adoCon = ObjCreate ("ADODB.Connection")
$adoCon.Open ($DSN)
$adoRs = ObjCreate ("ADODB.Recordset")
;You must Clear Operation Table in Destination mdb if not an error happen
$adoSQL = "SELECT * INTO Operation IN " & "'" & "CPTSTE.mdb" & "'" & " FROM Operation;"
$adocon.Open(  $adosql , $adors,$adOpenStatic, $adLockOptimistic)
$adoRs=""
$adocon.close
$adoCon=""

See always randallc post which treat of the same things with anoyther way

Thank you LouLou,

That sounds the most logical.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0