Articles → ADO.NET → ExecuteScalar method in ado.net

ExecuteScalar method in ado.net




Introduction





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