Hi,
I have managed to create a connection via SQL Compact server to a local SDF database. I am able to query the data and retrieve the information. The only problem is trying to delete a record. When I run the code no error's are produced but the record is still there even after refreshing the table. Any ideas? Thanks.
private void buttDel_Click(object sender, EventArgs e)
{
SqlCeConnection conn = null;
try
{
//Connect to database
conn = new SqlCeConnection("Data Source=Database1.sdf; Persist Security Info=False");
conn.Open();
if (txtName.Text != "")
{
SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = "DELETE FROM SignIn WHERE Username='" +txtName.Text + "'";
cmd.ExecuteNonQuery();
label29.Text = "User(" + txtName.Text+ ")has been deleted";
}
}
catch (Exception p)
{
string errorString = p.Message;
MessageBox.Show(errorString);
}
finally
{
conn.Close();
}
}