In a project, I have a local database, (I am using the datagrid to view the data), but the problem is that when I insert into database using the insertion query, the insertion is not lasting, i.e. when I rerun the application, the database is not changed and the changes are not reflected in the database view (view table data in Visual Studio).
The insertion query is:
string dbCon = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName + "\\MyDatabase.sdf";
SqlCeConnection dbconnection = new SqlCeConnection("datasource=" + dbCon);
dbconnection.Open();
String Insert = "insert into MainTable(LineID,Date,Connection_Type) Values('5','5/8/2012','commercial')";
SqlCeCommand cmd = new SqlCeCommand(Insert, dbconnection);
//// Execute the command
cmd.ExecuteNonQuery();
dbconnection.Close();
Now when this code runs, the datagrid is updated, but the changes are not permanent. What is it that I am doing wrong? I am using Visual Studio 2010 Ultimate and Windows 7