0

Hi
I am trying to delete a name from my database however my code seems to have a problem. It seems to cut out before i actually excutes the SQL statement. Is there something else i have missed in the code. PatientNumber is equal to the value to the text.
This is reading the value for i put MessageBox in to see

I am using C# compact framework and sql ce if it makes any differences

thanks for any help

SqlCeConnection  connDB = new SqlCeConnection("Data Source = \\My Documents\\system.sdf");
connDB.Open();
SqlCeCommand sqlDelete = connDB.CreateCommand();
sqlDelete.CommandText = "DELETE FROM Patient WHERE (((name)= + '"PatientName"'+");)"); 		
sqlDelete.ExecuteNonQuery();
connDB.Close();
2
Contributors
2
Replies
4
Views
11 Years
Discussion Span
Last Post by student_help
0

try this

SqlCeConnection  connDB = new SqlCeConnection("Data Source = \\My Documents\\system.sdf");
connDB.Open();
SqlCeCommand sqlDelete = connDB.CreateCommand();
sqlDelete.CommandText = "DELETE FROM Patient WHERE name= '"+ PatientName+ "'"; 		
sqlDelete.ExecuteNonQuery();
connDB.Close();
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.