954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Deleting from database

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();
student_help
Newbie Poster
8 posts since Feb 2006
Reputation Points: 10
Solved Threads: 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();
campkev
Posting Pro in Training
484 posts since Jul 2005
Reputation Points: 14
Solved Threads: 19
 

Hi thanks that worked.

student_help
Newbie Poster
8 posts since Feb 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You