ExecuteOracleScalar Method

OracleCommand.ExecuteOracleScalar Method

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Executes the query, and returns the first column of the first row in the result set returned by the query as an Oracle-specific data type. Extra columns or rows are ignored.

[Visual Basic]
Public Function ExecuteOracleScalar() As Object
[C#]
public object ExecuteOracleScalar();
[C++]
public: Object* ExecuteOracleScalar();
[JScript]
public function ExecuteOracleScalar() : Object;

Return Value

The first column of the first row in the result set as an Oracle-specific data type, or a null reference if the result is a REF CURSOR.

Remarks

Use the ExecuteOracleScalar method to retrieve a single value (for example, an aggregate value) from a database. This requires less code than using the ExecuteReader method, and then performing the operations necessary to generate the single value from the data returned by an OracleDataReader.

A typical ExecuteOracleScalar query can be formatted as in the following C# example:

cmd.CommandText = "select count(*) as NumberOfRegions from region";
count = cmd.ExecuteOracleScalar();

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

OracleCommand Class | OracleCommand Members | System.Data.OracleClient Namespace

Show:
© 2016 Microsoft