SQL

Please take into consideration using Named Parameters instead of the formatted strings as in the examples below.

SQL (using named parameters)

SelectValue

Read a single Value from the DataBase. If no value could be found, the NoSqlResultException is thrown. If more than one value is found, the InvalidOperationException is thrown.

int max = Sql.SelectValue("SELECT  MAX(nr)  FROM  versand_vorschlag ").ToInt(0);

SelectRow

Selects multiple values from the DataBase. All values have the same where-clause. Returns NULL if no result is found.

var resultRow = Sql.SelectRow(
    "Select lager_nr, bestand from bestand where lager_nr = {0} and art_nr = '{1}'",
    versandRow.lager_nr, versandRow.artnr);

SelectTable

Select multiple values and rows from the DataBase. Returns NULL if no rows are found.

DataTable resultRows = Sql.SelectTable(
    "Select lager_nr, lagerort, charge, seriennr, bestand, fifodatum from bestand_detail where lager_nr = {0} and art_nr = '{1}'",
     versandRow.lager_nr, versandRow.artnr);

TrySelectValue

Read a single Value from the DataBase.

No exceptions are thrown but the results are returned in the ret variable.

Methods interrogating the db

Last updated