11-04-2015 06:10 PM
Hello, I am using the following code to create a connection to an Access database:
libname elrdb PCFILES path="C:\mlt.accdb" scan_text=no usedate=yes;
This line fails to work if I have a form open in the database in design view. The message is:
ERROR: CLI error trying to establish connection: [Microsoft][ODBC Microsoft Access Driver] The
database has been placed in a state by an unknown user that prevents it from being opened or
ERROR: Error in the LIBNAME statement.
What is the recommended solution to this? I have added to the SAS code to quit SAS if one of the datasets created from a table in database contains 0 rows (which would indicate that a connection was not made and I should not continue processing).. but I would like to avoid putting these traps in throughout the code.
Is there a way to prevent an Access database from being opened such that SAS cannot get the access it needs in order to make the libname connection?
11-05-2015 06:12 PM
A simple way of preventing this would be to set the Access database file as read-only via the Windows file properties.
Please note Access is not designed to be a full multi-user database, so as a general rule it is safest for no-one else to be using it while you are reading it.
11-06-2015 10:42 AM
Since just opening an Access database in Access locks it, at least in my system, another application cannot get lock.If you look at the folder with the database open you'll see a file with the same name as your database but the extension of laccdb (for Access 2007 and later). The L stands for lock and you'll likely see a little padlock on the icon.
You'll see a similar error trying to read an Excel file open in Excel.
Quickest solution: close the Access database.
11-07-2015 02:27 AM