I am developing window phone 7 application. I am new to the Window Phone 7 application development. I want to use the SQL server compact edition database in my application for database connectivity. So in my application I have created the database by right clicking the ‘Data Connection’ & Choosing the ‘Add Connection’ in Server Explorer. After that I have created the database by using the Create button in the opened window.Then I have tested my connection. It was successful. I have added that created database file in my application by right clicking on the Project Name & choosing the add existing item. The database file was added as the ‘ExpenseManagerDB.sdf’ I have created the tables for this database by using the Server Explorer. Now I want to programmatically do the database connectivity for my application. So I am using the following code
namespace ExpenseMgrMobAppl.Category
{
public partial class Category : PhoneApplicationPage
{
private void Submitbutton_Click(object sender, RoutedEventArgs e)
{
string conSTR = "Data Source=" + (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)) + "\\ExpenseManagerDB.sdf;Persist Security Info=False";
SqlCeConnection connection = new SqlCeConnection(conSTR);
SqlCeCommand cmd = new SqlCeCommand("select category_name form category where category_id=1", connection);
connection.Open();
textBlock1.Text = cmd.ExecuteScalar.ToString();
connection.Close();
}
}
}
But I am not finding any Namespace/Assembly for the SqlCeConnection class. I have also tried to add reference to the dll ‘System.Data.SqlServerCE.dll’ in my application. But the reference could not be added. What should I need do for database connectivity ? What I need to do to use the SqlCeConnection class in my application ? I am looking for thing from which I can use the SqlCeConnection class in my application ? Can you please provide me any solution or link through which I can resolve the above issue ? If I am doing anything wrong in above case then please guide me.
SQL CE is not available in this release of the tools.
The alternatives are storage behind a web service, 3rd party db sources like Sterling or local storage in files using for example XML and LINQ.