944,147 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 4491
  • C# RSS
Mar 28th, 2006
0

Deleting from database

Expand Post »
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

C# Syntax (Toggle Plain Text)
  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.  
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
student_help is offline Offline
8 posts
since Feb 2006
Mar 29th, 2006
0

Re: Deleting from database

try this
C# Syntax (Toggle Plain Text)
  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();
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
Mar 30th, 2006
0

Re: Deleting from database

Hi thanks that worked.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
student_help is offline Offline
8 posts
since Feb 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: using Scripting;
Next Thread in C# Forum Timeline: Error Throwing In Calculator Code When Divided By '0'





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC