Articles → ADO.NET → Executescalar Method In Ado.Net

Executescalar Method In Ado.Net






Prerequisite





Sample




SqlConnection conn = new SqlConnection("<Connection_String>");
SqlCommand cmd =  new SqlCommand("<Select_Query>",conn);
conn.Open();
int count = (int)cmd.ExecuteScalar();
conn.Close();
conn.Dispose();












int count = (int)cmd.ExecuteScalar();




object IsUserValid;
IsUserValid = accessObject.ExecuteScalar(query);
if (IsUserValid != null) {
  int count = (int) IsUserValid;
}



Multiple Records With Executescalar() Function





Conclusion





Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, November 30, 2011

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250