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;
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.
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();
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:
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries From Partially Trusted Code