A. martinod Posted July 19, 2006 Share Posted July 19, 2006 (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 July 19, 2006 by A. martinod Link to comment Share on other sites More sharing options...
Squirrely1 Posted July 21, 2006 Share Posted July 21, 2006 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 Link to comment Share on other sites More sharing options...
nfwu Posted July 21, 2006 Share Posted July 21, 2006 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.#) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
Squirrely1 Posted July 21, 2006 Share Posted July 21, 2006 (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"). Edited July 21, 2006 by Squirrely1 Das Häschen benutzt Radar Link to comment Share on other sites More sharing options...
LOULOU Posted July 21, 2006 Share Posted July 21, 2006 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. 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 Link to comment Share on other sites More sharing options...
A. martinod Posted July 22, 2006 Author Share Posted July 22, 2006 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now