Advantage .NET Data Provider
Executes the query, and returns the first column of the first row in the result set returned by the query. Extra columns or rows are ignored.
public object ExecuteScalar();
Use the ExecuteScalar method to retrieve a single value (for example, an aggregate value) from a database. This requires less code than using the AdsCommand.ExecuteReader method and the associated calls to the AdsDataReader.
AdsConnection conn = new AdsConnection( "data source = c:\\data;" );
AdsCommand cmd;
// open the connection
conn.Open();
// create a new command object
cmd = conn.CreateCommand();
// specify a query
cmd.CommandText = "select now() from system.iota";
// execute the query
Console.WriteLine( cmd.ExecuteScalar().ToString() );
// find number of rows in a table
cmd.CommandText = "select count(*) from departments";
// execute the query
Console.WriteLine( cmd.ExecuteScalar().ToString() );