Saturday, February 25, 2012

Connection error in sql server compact edition 2005

HI friends,

i m working on device application ..i m using sql server ce 2005 with c#.net ... but when i m trying to connect to database it shows me error that

"the database path not found ... please check the path [,,,filename,,,]"

my code is as below

private string ConnStr = "Data Source =\\My Documents\\Employee.sdf;";

private void cmdCheckConnecton_Click(object sender, EventArgs e)
{
try
{
cn = new System.Data.SqlServerCe.SqlCeConnection(ConnStr);
cn.Open();
MessageBox.Show(cn.State.ToString());
}
catch (SqlCeException ex)
{
MessageBox.Show(ex.Message.ToString());
}
}

i have my database in My Documents and the path is right still it shows the error

pls help if any one have a solution regarding this problem

thanxx

Zalak Shah

This is just a guess, but looking at my connection strings they have quotes around the Data Source, so maybe try adding those in.

private string ConnStr = "Data Source =\"\\My Documents\\Employee.sdf\";";

|||hi

i have done it but still it doesn't work

one more thing i want to tell u .. if i create the database on the same location even it is there it will create once again and no files will be create at that location that 's just a file in a memory .... and after that that memory file will accessed by that code and working perfectly as i needed

can u tell me one thing that location is in mobile device (Emulator) 's location or my hard drive's location

No comments:

Post a Comment