We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Platform : ASP.NET
|
Category : DataGrid

Why do I get "Could not lock file" and "cannot open file" exceptions when bound to a mdb file?

You could get this error for the following reasons:
  1. When you create a project afresh, add a new OleDbDataAdapter to the form and link to the mdb file, the connection object created in the process will keep an open connection to the mdb file which is what will cause the above "Could not lock file" exception during runtime. To workaround this, go to "Server Explorer" in your IDE, right click on the corresponding "Connection entry" and select Close Connection. This should fix the problem.
  2. The "cannot open file" exception could then occur if you have not provided enough permissions on the mdb file to allow the .net runtime to lock it. To ensure enough permissions, open it’s properties, select the Security tab and add a "Everyone" account granting "Full Control" to it. This should let the .net runtime lock the file.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.