Dear Friends
I am a newbie and developing a project for my BSc CS.
In VS 2010, using c# and local database .sdf file (SQLCE).
application runs fine but it DOES NOT GET UPDATED in SQL DATABASE. but displays the new record in data grid view below my code. Please help what i should change?
surprisingly no Errors r exceptions messages even after adding try - catch.
TO FILL DATA GRID VIEW FROM THE SDF FILE -- SVITMS.SDF
---------------------------------------------------------
void FillData()
{
using (SqlCeConnection c = new SqlCeConnection(@"Data Source=D:\Library_MGMT 3\Library_MGMT\SVITMS.sdf"))
{
c.Open();
// Create new DataAdapter
using (SqlCeDataAdapter a = new SqlCeDataAdapter("SELECT * FROM BooksTbl", c))
{
DataTable t = new DataTable();
a.Fill(t);
BooksdataGridView.DataSource = t;
}
c.Close();
}
INSERT COMMAND BUTTON CLICK EVENT - table name = BooksTbl
-------------------------------------
private void Insertbutton_Click(object sender, EventArgs e)
{
SqlCeConnection c = new SqlCeConnection(@"Data Source=D:\Library_MGMT 3\Library_MGMT\SVITMS.sdf");
c.Open();
SqlCeCommand cmd = c.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Insert into BooksTbl values('" + ACCTextBox.Text + "','" + AuthorTextBox.Text + "'" )";
cmd.ExecuteNonQuery();
FillData();
}