Hi I am working with C# compact framwork. At the moment I am trying to add rows to a sqlce database accept i have an bug in my code which i am not able to fix. Would anyone be able to advise me where i am going wrong. The way i believe that this code is set up is that when the user clicks on the add button on the screen it takes the details from the text boxes and place the values in the database. Am I right in this and why is it not finishing the method. I am notgetting an error message the program is just freezing.
Thanks for any help possible
private void miAdd_Click(object sender, System.EventArgs e)
{
if(txtName.Text=="")
{
MessageBox.Show("Please enter a name");
}
if(txtName.Text != "" & txtPatID.Text !="")
{
SqlCeConnection connDB = new SqlCeConnection ("Data Source ="+ @"\My Documents\\system.sdf");
connDB.Open();
SqlCeCommand cmdDB = new SqlCeCommand();
SqlCeCommand sqlInsertRow = connDB.CreateCommand();
sqlInsertRow.CommandText = "INSERT INTO Patient(patID, f_name) VALUES('?','?')";
sqlInsertRow.Parameters.Add(new SqlCeParameter("patID", SqlDbType.Int)).Value = txtPatID.Text;
sqlInsertRow.Parameters.Add(new SqlCeParameter("f_name", SqlDbType.NText)).Value = txtName.Text;
sqlInsertRow.ExecuteNonQuery();
}
}