Db

Assembly: ZennoLab.CommandCenter
Full name: ZennoLab.CommandCenter.ZennoPoster.Db
Kind: abstract


Represents a set of methods to access database.

Methods

ExecuteNonQuery

Method

int ExecuteNonQuery(string query, OrderedDictionary param, DbProvider provider, string connectionString, bool throwExceptions)

Executes a SQL statement against the connection and returns the number of rows affected.

Parameters

TypeNameDescription
stringquerySQL query.
OrderedDictionaryparamQuery parameters.
DbProviderproviderData provider type.
stringconnectionStringConnection string.
boolthrowExceptionsIf true, exceptions will not be supressed. Default is false.

Returns: The number of rows affected.

Example

var rowCount = ZennoPoster.Db.ExecuteNonQuery("DELETE FROM User WHERE Id = 2", null,
                ZennoLab.InterfacesLibrary.Enums.Db.DbProvider.SqlClient,
                "Data Source=SQLSERVER;Initial Catalog=TestDb;Integrated Security=True;max pool size=500");

Example2

$rowCount = ZennoLab\CommandCenter\ZennoPoster::Db::ExecuteNonQuery("DELETE FROM User WHERE Id = 2", null,
                ZennoLab\InterfacesLibrary\Enums\Db\DbProvider::SqlClient,
                "Data Source=SQLSERVER;Initial Catalog=TestDb;Integrated Security=True;max pool size=500",False);

ExecuteScalar

Method

string ExecuteScalar(string query, OrderedDictionary param, DbProvider provider, string connectionString, bool throwExceptions)

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.

Parameters

TypeNameDescription
stringquerySQL query.
OrderedDictionaryparamQuery parameters .
DbProviderproviderData provider type.
stringconnectionStringConnection string.
boolthrowExceptionsIf true, exceptions will not be supressed. Default is false.

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

Example

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");

Example2

$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",False);

ExecuteQuery

Method

int ExecuteQuery(string query, OrderedDictionary param, DbProvider provider, string connectionString, IZennoTable& table, bool throwExceptions)

Parameters

TypeNameDescription
stringquery
OrderedDictionaryparam
DbProviderprovider
stringconnectionString
IZennoTable&table
boolthrowExceptions

ExecuteQuery

Method

int ExecuteQuery(string query, OrderedDictionary param, DbProvider provider, string connectionString, IZennoList& list, string separator, bool throwExceptions)

Parameters

TypeNameDescription
stringquery
OrderedDictionaryparam
DbProviderprovider
stringconnectionString
IZennoList&list
stringseparator
boolthrowExceptions

ExecuteQuery

Method

string ExecuteQuery(string query, OrderedDictionary param, DbProvider provider, string connectionString, string fieldSeparator, string rowSeparator, bool throwExceptions)

Execute SQL query and return result as string.

Parameters

TypeNameDescription
stringquerySQL query.
OrderedDictionaryparamQuery parameters .
DbProviderproviderData provider type.
stringconnectionStringConnection string.
stringfieldSeparatorField separator.
stringrowSeparatorRow separator. If null - System.Environment.NewLine.
boolthrowExceptionsIf true, exceptions will not be supressed. Default is false.

Returns: Result string.

Example

var result = ZennoPoster.Db.ExecuteQuery("SELECT * FROM User", null,
                ZennoLab.InterfacesLibrary.Enums.Db.DbProvider.SqlClient, 
                "Data Source=SQLSERVER;Initial Catalog=TestDb;Integrated Security=True;max pool size=500", " | ");

Example2

$result = ZennoLab\CommandCenter\ZennoPoster::Db::ExecuteQuery("SELECT * FROM User", null,
                ZennoLab\InterfacesLibrary\Enums\Db\DbProvider::SqlClient, 
                "Data Source=SQLSERVER;Initial Catalog=TestDb;Integrated Security=True;max pool size=500", " | ",False);