Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 » UltraLite - .NET Programming » UltraLite .NET 2.0 API reference » ULCommand class


ExecuteScalar method

Executes a SQL SELECT statement and returns a single value.

Visual Basic
Public Overrides Function ExecuteScalar() As Object
public override object ExecuteScalar();
Return value

The first column of the first row in the result set, or a null reference (Nothing in Visual Basic) if the result set is empty.


The statement is the current ULCommand object, with the ULCommand.CommandText and any ULCommand.Parameters as required.

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

If the ULCommand.CommandType is System.Data.CommandType.TableDirect, ExecuteScalar performs an ULCommand.ExecuteTable() and returns the first column of the first row.

SELECT statements are marked as read-only by default for performance reasons. If the query is going to be used to make updates, the statement must end with " FOR UPDATE".

See also