Hi,
What is wrong with this one
SqlConnection con = new SqlConnection("Server=.\\SQLExpress;Database=patient;uid=sa;pwd=;");
String Query;
Query = "Delete from PatientRecords where PatientID='" + TextBox1.Text + "'";
SqlCommand sqlcmb = new SqlCommand();
con.Open();
sqlcmb.Connection = con;
SqlTransaction sqltran;
sqltran = con.BeginTransaction();
sqlcmb.Transaction = sqltran;
sqlcmb.CommandText = Query;
sqlcmb.ExecuteNonQuery();
Thanks in Advance,
A.Durga Prasad
Loading

Ryan AlfordRank #1,411 · 1.2K reputationPosted Mar 24, 2009, 9:14 AM EDT
akhil18 reputationPosted Mar 25, 2009, 12:50 AM EDT
just tell what problem u are facing
then only we can help u
Is there problem in connection or not deleting record or else so pls be specific with question
akhilesh
Rama bandapelli10 reputationPosted Mar 25, 2009, 8:13 AM EDT
It depends on what datatype PatientId is TextBox1.text passes a string value with some empty charecters some time, use textbox1.text.Trim().
Amit TiwariRank #9,518 · 205 reputationPosted Mar 25, 2009, 2:42 PM EDT
durga prasad36 reputationPosted Mar 25, 2009, 9:16 PM EDT
data base (ex. The Values is not getting deleted from database).
durga prasad36 reputationPosted Mar 25, 2009, 9:54 PM EDT
SqlConnection con = new SqlConnection("Server=.\\SQLExpress;Database=patient;uid=sa;pwd=;");
String Query;
Query = "Delete from PatientRecords where PatientID='" + txtPatientID.Text + "'";
SqlCommand sqlcmb = new SqlCommand();
con.Open();
sqlcmb.Connection = con;
SqlTransaction sqltran;
sqltran = con.BeginTransaction();
sqlcmb.Transaction = sqltran;
sqlcmb.CommandText = Query;
sqlcmb.ExecuteNonQuery();
sqltran.Commit(); //Missing this line