Gemstone Data Library
Show/Hide TOC

# AdoDataConnectionExecuteScalarAsync(Type, Object, Int32, String, CancellationToken, Object) Method

Executes the SQL statement using Connection, and returns the value in the first column of the first row in the result set as type returnType, substituting defaultValue if Value is retrieved.

## Definition

Namespace: Gemstone.Data
Assembly: Gemstone.Data (in Gemstone.Data.dll) Version: 1.0.160 -- Release Build+0b65775365098d82320afec1fcaed7affaca67e3
C#
View Source Request Example

    public Task<Object?> ExecuteScalarAsync(
    	Type returnType,
    	Object? defaultValue,
    	int timeout,
    	string sqlFormat,
    	CancellationToken cancellationToken,
    	params Object?[] parameters
    )

VB
View Source Request Example

    Public Function ExecuteScalarAsync (
    	returnType As Type,
    	defaultValue As Object,
    	timeout As Integer,
    	sqlFormat As String,
    	cancellationToken As CancellationToken,
    	ParamArray parameters As Object()
    ) As Task(Of Object)

C++
View Source Request Example

    public:
    Task<Object^>^ ExecuteScalarAsync(
    	Type^ returnType,
    	Object^ defaultValue,
    	int timeout,
    	String^ sqlFormat,
    	CancellationToken cancellationToken,
    	... array<Object^>^ parameters
    )

JavaScript
View Source Request Example

    function ExecuteScalarAsync(returnType, defaultValue, timeout, sqlFormat, cancellationToken, ... parameters);

#### Parameters

returnType Type
  The type to which the result of the query should be converted.
defaultValue Object
  The value to be substituted if Value is retrieved.
timeout Int32
  The time in seconds to wait for the SQL statement to execute.
sqlFormat String
  Format string for the SQL statement to be executed.
cancellationToken CancellationToken
  Propagates notification that operations should be canceled.
parameters Object
  The parameter values to be used to fill in DbParameter parameters.

#### Return Value

Task Object
Value in the first column of the first row in the result set.

## See Also

#### Reference

AdoDataConnection Class
ExecuteScalarAsync Overload
Gemstone.Data Namespace