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.164 -- Release Build+4792d58a5dfec79a98312666bfd5a0106e818d1d
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