The object DbConnection of the IJobRouterDbConnection type can be used to execute SQL queries directly on the database. However, we recommend to only use the direct database access if the required queries or changes cannot be made by using the provided API methods of the system activity. You also have to take into account that database changes made this way will be executed outside of the system activity transaction.
The following methods and properties can be used for the direct database access.
Signature |
Description |
|---|---|
void ExecuteSQL(string sql) |
Executes an SQL command. |
void ExecuteSQL(List<string> sqlList) |
Executes multiple SQL commands inside one transaction. |
DataTable GetData(string sql) |
Executes an SQL query and returns the result as DataTable. |
object GetDataScalar(string sql) |
Executes the passed SQL query and returns the first column of the first row of the result set returned by the query. Additional columns or rows are ignored. |
string QuoteString(string s) |
Masks the String, allowing it to be used securely in an SQL query. |
string DateTimeForSql(DateTime dateTime) |
Converts the passed DateTime object into a string in a format appropriate to the database type. |
DateTime CurrentDateTime |
Returns a DateTime object that contains the current date and time. |
string CurrentDateTimeForSql |
Returns a string in a format appropriate to the database type containing the current date and time. |
string LastError |
Returns the last database error message. |
The following example illustrates the implementation of a database query:
