Deleting from database

Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2006
Posts: 8
Reputation: student_help is an unknown quantity at this point 
Solved Threads: 0
student_help student_help is offline Offline
Newbie Poster

Deleting from database

 
0
  #1
Mar 28th, 2006
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

  1.  
  2. SqlCeConnection connDB = new SqlCeConnection("Data Source = \\My Documents\\system.sdf");
  3. connDB.Open();
  4. SqlCeCommand sqlDelete = connDB.CreateCommand();
  5. sqlDelete.CommandText = "DELETE FROM Patient WHERE (((name)= + '"PatientName"'+");)");
  6. sqlDelete.ExecuteNonQuery();
  7. connDB.Close();
  8.  
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 483
Reputation: campkev is an unknown quantity at this point 
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: Deleting from database

 
0
  #2
Mar 29th, 2006
try this
  1. SqlCeConnection connDB = new SqlCeConnection("Data Source = \\My Documents\\system.sdf");
  2. connDB.Open();
  3. SqlCeCommand sqlDelete = connDB.CreateCommand();
  4. sqlDelete.CommandText = "DELETE FROM Patient WHERE name= '"+ PatientName+ "'";
  5. sqlDelete.ExecuteNonQuery();
  6. connDB.Close();
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 8
Reputation: student_help is an unknown quantity at this point 
Solved Threads: 0
student_help student_help is offline Offline
Newbie Poster

Re: Deleting from database

 
0
  #3
Mar 30th, 2006
Hi thanks that worked.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 2353 | Replies: 2
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC