Gemstone Data Library
Show/Hide TOC

# DataExtensionsExecuteScalar(DbConnection, String, Object) Method

Executes the SQL statement using DbConnection, and returns the value in the first column of the first row in the result set.

## Definition

Namespace: Gemstone.Data.DataExtensions
Assembly: Gemstone.Data (in Gemstone.Data.dll) Version: 1.0.138 -- Release Build+f7ceb3e02ea3c92b27e86b99ae16cee337a20b9e
C#
View Source Request Example

    public static Object? ExecuteScalar(
    	this DbConnection connection,
    	string sql,
    	params Object?[] parameters
    )

VB
View Source Request Example

    <ExtensionAttribute>
    Public Shared Function ExecuteScalar (
    	connection As DbConnection,
    	sql As String,
    	ParamArray parameters As Object()
    ) As Object

C++
View Source Request Example

    public:
    [ExtensionAttribute]
    static Object^ ExecuteScalar(
    	DbConnection^ connection,
    	String^ sql,
    	... array<Object^>^ parameters
    )

JavaScript
View Source Request Example

    Gemstone.Data.DataExtensions.DataExtensions.ExecuteScalar = function(connection, sql, ... parameters);

#### Parameters

connection DbConnection
  The DbConnection to use for executing the SQL statement.
sql String
  The SQL statement to be executed.
parameters Object
  The parameter values to be used to fill in DbParameter parameters identified by '@' prefix in sql expression.

#### Return Value

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

#### Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DbConnection. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

## See Also

#### Reference

DataExtensions Class
ExecuteScalar Overload
Gemstone.Data.DataExtensions Namespace