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