ExecuteScalar() method

Executes a statement that returns a single value.

Visual Basic syntax

Public Overrides Function ExecuteScalar () As Object

C# syntax

public override object ExecuteScalar ()

Returns

The first column of the first row in the result set, or a null reference if the result set is empty.

Usage

If this method is called on a query that returns multiple rows and columns, only the first column of the first row is returned.