ZennoLab Assemblies Documentation
ExecuteScalar Method
Example 
ZennoLab.CommandCenter Namespace > ZennoPoster.Db Class : ExecuteScalar Method

Type: System.String

SQL query.

Type: System.Collections.Specialized

Query parameters .

Type: ZennoLab.InterfacesLibrary.Enums.Db.DbProvider

Data provider type.

Type: System.String

Connection string.

Executes the query, and returns the first column of the first row in the result set returned by the query.Additional columns or rows are ignored.
Syntax

Parameters

query

Type: System.String

SQL query.

param

Type: System.Collections.Specialized

Query parameters .

provider

Type: ZennoLab.InterfacesLibrary.Enums.Db.DbProvider

Data provider type.

connectionString

Type: System.String

Connection string.

Return Value

Type: System.String

The first column of the first row in the result set or empty string

Remarks

Example
The following example shows call the ExecuteScalar method.
var count = ZennoPoster.Db.ExecuteScalar("SELECT COUNT(*) FROM User", null,
    ZennoLab.InterfacesLibrary.Enums.Db.DbProvider.SqlClient, 
    "Data Source=SQLSERVER;Initial Catalog=TestDb;Integrated Security=True;max pool size=500");
$count = ZennoLab\CommandCenter\ZennoPoster::Db::ExecuteScalar("SELECT COUNT(*) FROM User", null,
    ZennoLab\InterfacesLibrary\Enums\Db\DbProvider::SqlClient,
    "Data Source=SQLSERVER;Initial Catalog=TestDb;Integrated Security=True;max pool size=500");
Requirements

Target Platforms: Desktop: Windows XP SP3 and older. Server: Windows Server 2003 and older.

See Also

Reference

ZennoPoster.Db Class
ZennoPoster.Db Members
ExecuteNonQuery Method
ExecuteQuery Method