'Declaration Public Overrides NotOverridable Function ExecuteScalar() As Object
public override object ExecuteScalar()
public: Object^ ExecuteScalar(); override
Return Value
The first column of the first row.
'Declaration Public Overrides NotOverridable Function ExecuteScalar() As Object
public override object ExecuteScalar()
public: Object^ ExecuteScalar(); override
Exception | Description |
---|---|
System.IndexOutOfRangeException | Can be thrown because of one of the following errors: 1) The TdParameter.Offset is outside of 0 through array size � 1 2) More in-out/out parameters have been specified than returned from the stored procedure. |
System.InvalidCastException | One or more parameters cannot be converted to Teradata native types. |
System.InvalidOperationException | Can be thrown because of one of the following errors: 1) TdConnection is not in the Open state or is null or 2) The local transaction associated with TdCommand is not the same local transaction associated with the TdConnection. |
System.ObjectDisposedException | The TdCommand is closed or disposed. |
TdException | Can be thrown because of one of the following errors: 1) Teradata returned an error or 2) The Data Provider detected an error. |
Executes the SQL statement and returns the first column of the first row.
When CommandType property is set to System.Data.CommandType.StoredProcedure, any output parameters are populated with data and a null object reference is returned.
public Object ExecuteQuery(string connectionString, string commandText) { Object scalar; using(TdConnection cn = new TdConnection(connectionString)) { cn.Open(); TdCommand cmd = new TdCommand(commandText, cn); scalar = cmd.ExecuteScalar(); } return scalar; }
Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019