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();

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();

Hi thanks that worked.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.