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 override object ExecuteScalar()
'Declaration
Public Overrides Function ExecuteScalar() As Object
Return Value
The first column of the first row in the result set.
This example shows typical usage of
ExecuteScalar method
using(MailChimpConnection conn = new MailChimpConnection(connectionString)) {
conn.Open();
MailChimpCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT count(*) as NumberOfRegions FROM regions";
Int64 count = Convert.ToInt64(cmd.ExecuteScalar());
}
Dim conn As New MailChimpConnection(connectionString)
conn.Open()
Dim cmd As MailChimpCommand = conn.CreateCommand()
cmd.CommandText = "SELECT count(*) as NumberOfRegions FROM regions"
Dim count As Int64 = Convert.ToInt64(cmd.ExecuteScalar());
conn.Close()