BookmarkSubscribeRSS Feed
ucdcrush
Obsidian | Level 7

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
locked.
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?

Thank you.

3 REPLIES 3
SASKiwi
PROC Star

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.

ballardw
Super User

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.

LinusH
Tourmaline | Level 20
What is the use pattern for this db?
If you need multi user access move the data to SQL Server. You could still use the MS Access forms in this scenario.
Data never sleeps

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1288 views
  • 0 likes
  • 4 in conversation