tags:

views:

16

answers:

2
  • For Acccess Database which open with Message "This database has been opended read-only".

  • For this DB when we connect using C#.net application with OleDbconnectio ..at time of updating Query it give Error "Operation must use an updateable query."

  • I just want to prompt user if DB opened with ReadOnly Permission In Access Database.. how can we add code in C#.net application to identiy oledb database ReadOnly Permission.

Thanks

A: 

You can use FileInfo

FileInfo f = new FileInfo(@"C:\MyDb.accdb");
if (f.IsReadOnly)
{
    Console.WriteLine("File is Read only");
}
else
{
    Console.WriteLine("File is Not Read Only");
}
RandomNoob
A: 

As far as I can remember, Access can deny you writes despite the fact that database file is writable.

Best way to check it is to try to insert some dummy value right after opening the database. Catch the exception and inform the user.

Daniel Mošmondor