Db
Assembly: ZennoLab.CommandCenter
Full name: ZennoLab.CommandCenter.ZennoPoster.Db
Represents a set of methods to access database.
Methods
ExecuteNonQuery
Method
Executes a SQL statement against the connection and returns the number of rows affected.
Parameters
| Параметр | Описание |
|---|---|
query | SQL query. |
param | Query parameters. |
provider | Data provider type. |
connectionString | Connection string. |
throwExceptions | If 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
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
| Параметр | Описание |
|---|---|
query | SQL query. |
param | Query parameters . |
provider | Data provider type. |
connectionString | Connection string. |
throwExceptions | If 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
Execute SQL query and fill table.
Parameters
| Параметр | Описание |
|---|---|
query | SQL query. |
param | Query parameters. |
provider | Data provider type. |
connectionString | Connection string. |
table | Table for result data. |
throwExceptions | If true, exceptions will not be supressed. Default is false. |
Returns: The number of rows affected.
Example
var table = project.Tables["Table 1"];
var rowCount = 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",
ref table);Example2
$table = $project.Tables["Table 1"];
$rowcount = 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",
$table,False);ExecuteQuery
Method
Execute SQL query and fill list.
Parameters
| Параметр | Описание |
|---|---|
query | SQL query. |
param | Query parameters . |
provider | Data provider type. |
connectionString | Connection string. |
list | List for result data. |
separator | Field separator. |
throwExceptions | If true, exceptions will not be supressed. Default is false. |
Returns: The number of rows affected.
Example
var list = project.Lists["List 1"];
var rowCount = 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",
ref list, " | ");Example2
$list = $project.Lists["Table 1"];
$rowcount = 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",
$list, " | ",False);ExecuteQuery
Method
Execute SQL query and return result as string.
Parameters
| Параметр | Описание |
|---|---|
query | SQL query. |
param | Query parameters . |
provider | Data provider type. |
connectionString | Connection string. |
fieldSeparator | Field separator. |
rowSeparator | Row separator. If null - System.Environment.NewLine. |
throwExceptions | If 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);