I am using esxiting .sdf file in my windows phone application. When i tried open the database am getting error like : Access to the database file is not allowed [1981,Filename='\Applications\install\OFC425F3-22CC-4A60-A815-40FE......\install\Countries.sdf,SeCreateFile]
My Code :
private const string strConnectionString = "Data Source = 'appdata:/Countries.sdf'";
private void Button_Click_1(object sender, RoutedEventArgs e)
{
try
{
IList<Country> countryList = this.GetCountryList();
}
catch (Exception c)
{
MessageBox.Show(c.Message);
}
}
public IList<Country> GetCountryList()
{
// Fetching data from local database
IList<Country> countryList = null;
try
{
using (CountryDataContext countryDB = new CountryDataContext(strConnectionString))
{
IQueryable<Country> countryQuery = from _contry in countryDB._countries select _contry;
// MessageBox.Show(countryQuery.Count().ToString());
countryList = countryQuery.ToList();
}
}
catch (Exception c)
{
MessageBox.Show(c.Message);
}
return countryList;
}
When i tried with this
private const string strConnectionString = "Data Source = 'appdata:/Countries.sdf'; File Mode =read only;";
am getting error like : the dB is opened with read-only connection. Can't perform post-initialization operations like rebuilding indexes and upgrading the public tracking.Please re-open with read-write connection.
How to open database in read-write mode ? is there any permission requirred to open database(Database is not password protected)?