I am work on smartApplication, Here when am trying to connect to my SQL Server CE 2005 database, I get the exception
The path is not valid. Check the directory for the database. [ Path = D:\SmartProject\DBFile.sdf ]
My connection string is
Data Source=D:\SmartProject\DBFile.sdf;Password=test123
and the code to connect is like
string connectionString = "Data Source=D:\\SmartProject\\DBFile.sdf;Password=test123";
SqlCeConnection Connection = new SqlCeConnection(connectionString);
SqlCeCommand comm = new SqlCeCommand(SqlSelectCommandText, Connection);
SqlCeDataAdapter da = new SqlCeDataAdapter(comm);
DataSet ds = new DataSet();
try
{
Connection.Open();
da.Fill(ds);
if (ds.Tables.Count > 0)
dataTable = ds.Tables[0];
else
dataTable = new DataTable();
bsuccessfullyExecuted = true;
}
catch (SqlCeException ex)
{
bsuccessfullyExecuted = false;
dataTable = null;
}
finally
{
Connection.Close();
}
when the code try to open the connection it throw this exception provided the file is at the specified location or directory.
It works when I just place the DBFile.sdf file with the .exe in bin and remove the path except the Database file name from connectionstring.
but when I try to access it through Emulator it show this error. provided that its connect through cradle and Windows Mobile Device center. It show all the page but when I try to access the Db it through exception..