Executes the SQL command and gets a scalar value.
[Visual Basic]
Public Function ExecuteScalar( _
ByVal sql As String, _
ByVal connectionControl As Boolean _
) As Object
[C#]
public object ExecuteScalar(
string sql,
bool connectionControl
);
Parameters
-
sql
- SQL.
-
connectionControl
- Value that indicates whether it controls the connection automatically.
Return Value
Returns scalar value if successful; otherwise null.
Remarks
If connectionControl is true, first of all the connection to the database is opened and at last it is closed.
Example
How to execute the SQL command that returns a maximum value of column from the table of database.
Dim obj As Object = dbData.ExecuteScalar("SELECT MAX(xxx_id) FROM xxxtbl", True)
object obj = dbData.ExecuteScalar("SELECT MAX(xxx_id) FROM xxxtbl", true);
See Also
AwDbData Class | Asterworld.Data Namespace