Session.ExecuteScalar(String) Method
Executes the specified SQL query and returns the first column of the first row in the result set returned by the query.
Namespace: DevExpress.Xpo
Assembly: DevExpress.Xpo.v18.2.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
sql | String | A String value that specifies an SQL query. |
Returns
Type | Description |
---|---|
Object | The first column of the first row in the query’s result set. If the column is not found in the result set, a null reference (Nothing in Visual Basic) is returned. If the value in the database is null, DBNull.Value is returned. |
Remarks
Use ExecuteScalar to query data stores for a single or aggregate value, without having to retrieve a result set.
To learn more about executing SQL queries in XPO, refer to Direct SQL Queries.
Note
The ExecuteScalar method sends queries directly, so the correct query syntax depends on a particular database server.
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ExecuteScalar(String) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.