I have a C# application that interacts with an Access database.
When I execute an OleDbCommand
object to ALTER
a table and ADD
a new column, I receive an error:
OleDbException: The database engine could not lock table because it is already in use by another person or process.
While I can manipulate my data successfully. However when I execute the query directly in the MS Access, it works correctly.
Note: my database is closed and no person or process is using it.
How can I resolve this?
Try this out
Use following connection string
db.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\<Your database name>;Persist Security Info=False;")
along with following additional property
In short, you need to open the database in exclusive mode to make an alter table query. or you can also set this property in the following manner in c#
I have not tested the code though but it should work for you.