SqlConnection con=new SqlConnection ("connectionstring"); con.Open (); SqlCommand cmd = new SqlCommand("select count(*) from tableName where cid=1233", con); int i = 0; i=(int)cmd.ExecuteScalar(); if (i > 0) { //record is available SqlCommand deleteCmd = new SqlCommand("delete tablename where cid=1233", con); int res = 0; res=deleteCmd.ExecuteNonQuery(); if (res > 0) { //deleted successfully } else { //failed to delete } } else { //there is no record }
SqlConnection con=new SqlConnection ("connectionstring");
SqlConnection
"connectionstring"
select count(*) from tableName where cid=1233
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)