I am developing C#-based mobile application and the exception always thrown and catched by my try catch block
Exceptin thrown : The database file cannot be found.Check the path to the database [File name = .\MyMobileDB.sdf]
the snippet code is
namespace DeviceApplication4
{
public partial class Form1 : Form
{
public string strCon = @"Data Source =.\MyMobilePhoneDB.sdf; Password =123@asu";
public SqlCeConnection SqlConn;
public SqlCeCommand CeCmd = new SqlCeCommand();
public SqlCeDataReader dataReader;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
SqlConn = new SqlCeConnection(strCon);
CeCmd.CommandText = strCon;
SqlConn.ConnectionString = strCon;
MessageBox.Show("After open");
SqlConn.Open();
MessageBox.Show("After open");
SqlConn.Close();
MessageBox.Show("After close");
}
catch (SqlCeException x)
{
MessageBox.Show( x.ToString());
}
}
}
}
This exception exception thrown at line 27 and displayed after being caught at line 36