Implements the IDbAccess functionality for Microsoft SQL Server database engine.
Default constructor
public Void SqlServerDbAccess()
Initializes a new instance of SqlServerDbAccess copying the data from source.
public Void SqlServerDbAccess(source)
Name | Type | Summary |
---|---|---|
source | SqlServerDbAccess | A SqlServerDbAccess to be copied. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when source is null. |
Whether the connection is encrypted.
public Nullable<Boolean> Encrypt { get; set; }
Name or address of the partner server to connect to if the primary server is down.
public String FailoverPartner { get; set; }
Get whether the database connection is opened.
public Boolean IsConnectionOpen { get; }
Get whether an opened connection is running a transaction.
public Boolean IsInTransaction { get; }
Password of the user used to connect to the database.
public String Password { set; }
Whether to trust on server certificate.
public Nullable<Boolean> TrustServerCertificate { get; set; }
User name to connecto to the database.
public String UserName { set; }
Adds a new parameter to the command passed as parameter.
public Void AddParameter(command, name, type, direction, size, value)
Name | Type | Summary |
---|---|---|
command | IDbCommand | The command where the parameter will be added. |
name | String | The quoted parameter name. |
type | DbType | The parameter data type. |
direction | ParameterDirection | The parameter direction. |
size | Int32 | The size of the data in the valueparameter. |
value | Object | The value of the parameter. |
Type | Summary |
---|---|
DataAccessException | Thrown when there are an error casting the parameter value. |
Initiates a database transaction.
public IDbTransaction BeginTransaction()
An object representing the new transaction.
Initiates a database transaction with the specified isolation level.
public IDbTransaction BeginTransaction(iso)
An object representing the new transaction.
Name | Type | Summary |
---|---|---|
iso | IsolationLevel | Isolation level for the transaction. |
Closes the database connection if it is opened.
public Void CloseConnection()
Commits the running database transaction.
public Void CommitTransaction()
Creates a new database command.
public IDbCommand CreateCommand(commandType)
An object representing the newly created command.
Name | Type | Summary |
---|---|---|
commandType | CommandType | Type of the command to create. |
Performs applicarion-defined tasks associated with freeing, releasing, or reseting unmaneged resources.
public Void Dispose()
Executes the specified command against the database.
public Int32 ExecuteCommand(command, tbl)
Amount of records affected by the command.
If the command returns a set of records, the tbl parameter must contain an initialize DataTable, otherwise it must be null
Name | Type | Summary |
---|---|---|
command | IDbCommand | Command to excecute. |
tbl | DataTable | An initialized DataTable object or null. |
Type | Summary |
---|---|
DataAccessException | Thrown when an unindentify error occurs. |
OpenConnectionException | Thrown when a connection could not be openned. |
DuplicatedPrimaryKeyException | Thrown when a primary key or unique index constraint fails. |
ConstraintViolationException | Thrown if a constraint is violated. |
DatabaseObjectNotFoundException | Thrown when a database object, as a table, view, field, etc., does not exist. |
Executes the specified command asyncronously againt the database.
public Task<Int32> ExecuteCommandAsync(command, dataTable)
If the command returns a set of records, the dataTable parameter must contain an initialized DataTable, otherwise it must be null.
Name | Type | Summary |
---|---|---|
command | IDbCommand | Command to execute. |
dataTable | DataTable | An initialized DataTable object or null. |
Type | Summary |
---|---|
DataAccessException | Thrown when an unindentify error occurs. |
DuplicatedPrimaryKeyException | Thrown when a primary key or unique index constraint fails. |
ConstraintViolationException | Thrown if a constraint is violated. |
DatabaseObjectNotFoundException | Thrown when a database object, as a table, view, field, etc., does not exist. |
Executes the specified command against the database and returns a IDataReader.
public IDataReader ExecuteReader(command)
A read only forward only IDataReader with the database data.
Name | Type | Summary |
---|---|---|
command | IDbCommand | Command to execute. |
Type | Summary |
---|---|
InvalidOperationException | Thrown the the connection is not open. |
DataAccessException | Thrown when an unindentify error occurs. |
DatabaseObjectNotFoundException | Thrown when a database object, as a table, view, field, etc., does not exist. |
Executes the specified command against the database asyncronously and returns an IDataReader.
public Task<IDataReader> ExecuteReaderAsync(command)
Name | Type | Summary |
---|---|---|
command | IDbCommand | Command to execute. |
Type | Summary |
---|---|
InvalidOperationException | Thrown when the database connection is not open. |
DataAccessException | Thrown when an unindentify error occurs. |
DatabaseObjectNotFoundException | Thrown when a database object, as a table, view, field, etc., does not exist. |
Executes the specified command against the database and returns the first fields of the first record retrieved.
public Object ExecuteScalar(command)
Value of the first field of the first record. If the CommandType is a Stored Procedure the value of the parameter with Direction equals to ReturnValue is returned.
Name | Type | Summary |
---|---|---|
command | IDbCommand | Command to excecute. |
Type | Summary |
---|---|
DataAccessException | Thrown when an unindentify error occurs. |
OpenConnectionException | Thrown when a connection could not be openned. |
DatabaseObjectNotFoundException | Thrown when a database object, as a table, view, field, etc., does not exist. |
Executes the specified command againts the database asyncronously and returns the first field of the first record retrieved.
public Task<Object> ExecuteScalarAsync(command)
Value of the first field of the first record. If the CommandType is a Stored Procedure the value of the parameter with Direction equals to ReturnValue is returned.
Name | Type | Summary |
---|---|---|
command | IDbCommand | Command to execute. |
Type | Summary |
---|---|
DataAccessException | Thrown when an unindentify error occurs. |
OpenConnectionException | Thrown when a connection could not be openned. |
DatabaseObjectNotFoundException | Thrown when a database object, as a table, view, field, etc., does not exist. |
Ejecutes the underlaying connection GetSchema() method.
public DataTable GetSchema()
A DataTable as obtained from the GetSchema() method.
Type | Summary |
---|---|
DataAccessException | Thrown when an unindentify error occurs. |
Ejecutes the underlaying connection GetSchema() method.
public DataTable GetSchema(collectionName)
A DataTable as obtained from the GetSchema() method.
Name | Type | Summary |
---|---|---|
collectionName | String | The name of the collection to retrieve. |
Type | Summary |
---|---|
DataAccessException | Thrown when an unindentify error occurs. |
Ejecutes the underlaying connection GetSchema() method.
public DataTable GetSchema(collectionName, restrictionValues)
A DataTable as obtained from the GetSchema() method.
Name | Type | Summary |
---|---|---|
collectionName | String | The name of the collection to retrieve. |
restrictionValues | String[] | A set of restriction values. |
Type | Summary |
---|---|
DataAccessException | Thrown when an unindentify error occurs. |
Gets the server version.
public String GetServerVersion()
The server version.
This method returns the compatibility level of the database configured in the DataAccessAPI property as:
When 65 then SQL Server 6.5
When 70 then SQL Server 7.0
When 80 then SQL Server 2000
When 90 then SQL Server 2005
When 100 then SQL Server 2008/2008R2
When 110 then SQL Server 2012
When 120 then SQL Server 2014
When 130 then SQL Server 2016
When 140 then SQL Server 2017
Else new unknown.
Type | Summary |
---|---|
SchemaManipulationException | Thrown when there is an error accesing schema data. |
MissingRequiredPropertyException | Thrown when the Catalog is not initialized. |
Opens a connection with the database server.
public Void OpenConnection()
Type | Summary |
---|---|
OpenConnectionException | Thrown when an unindentify error occurs. |
ServerUnavailableException | Thrown when the database server is not found. |
CatalogNotFoundException | Thrown when the catalog is not found. |
InvalidCredentialsException | Thrown when credentials are invalid. |
CredentialsExpiredException | Thrown when the password has expired. |
Opens a connection with the database server asyncronously.
public Task OpenConnectionAsync()
Type | Summary |
---|---|
OpenConnectionException | Thrown when an unindentify error occurs. |
ServerUnavailableException | Thrown when the database server is not found. |
CatalogNotFoundException | Thrown when the catalog is not found. |
InvalidCredentialsException | Thrown when credentials are invalid. |
CredentialsExpiredException | Thrown when the password has expired. |
Aborts the current transaction.
public Void RollbackTransaction()
In this document