if ( id exist) { do some thing} else //not exist {do some thing}
SqlCommand cmd = new SqlCommand("SELECT name FROM myTable WHERE id=1", con); string resultedname = (string)cmd.ExecuteScalar(); if (resultedname!="") { // id Exists } else { // id does not Exists }
SqlCommand cmd = new SqlCommand("SELECT * FROM myTable WHERE id=1234", con); SqlDataReader r = cmd.ExecuteReader(); if (r.Read()) { // id Exists }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)