ADO.NET ExecuteScalar in OleDbCommand Object
ExecuteScalar() in OleDbCommand Object is used for get a single value from Database after its execution. It executes SQL statements or Stored Procedure and returned a scalar value on first column of first row in the Result Set. If the Result Set contains more than one columns or rows , it takes only the first column of first row, all other values will ignore. If the Result Set is empty it will return a Null reference. It is very useful to use with aggregate functions like Count(*) or Sum() etc. When compare to ExecuteReader() , ExecuteScalar() uses fewer System resources.
connetionString = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = Your mdb filename;"
sql = "Your SQL Statement Here like Select Count(*) from product"
You have to replace the string with your realtime variables.