-
Notifications
You must be signed in to change notification settings - Fork 0
Description
When writing a table to the Access-file, I expect that I will need Exclusive access to the file. If that is the case, the script should test if I do have exclusive access before starting the data crunching.
One solution is to open the file connection with exclusive access. This will (hopefully) fail when someone has the file open.
Using DBI, this seemed to work (but is not implemented in the RMD file):
Connection string must contain "Exclusive=1;"
Code:
dbdriver <- "Driver={Microsoft Access Driver (*.mdb, *.accdb)};Exclusive=1;DBQ="
dbname <- paste(DBroot, KH_db, sep = "/") # Har satt opp parameterne i første chunk.
dbconn <- DBI::dbConnect(odbc::odbc(),
.connection_string = paste0(dbdriver, dbname),
encoding = "latin1")
This opened the connection when the Access file was closed, but failed when the file was open in an Access window. "The file is already in use".