AdoDataConnection Class

Creates a new IDbConnection from any specified or configured ADO.NET data source.

Definition

Namespace: Gemstone.Data
Assembly: Gemstone.Data (in Gemstone.Data.dll) Version: 1.0.110 -- Release Build+b4bcf74734aa051a9b802d8f3f6ec05bd02af749
public class AdoDataConnection : IDisposable
Inheritance
Object    AdoDataConnection
Implements
IDisposable

Remarks

Example connection and data provider strings:
Database typeExample connection string / data provider string
SQL Server ConnectionString = "Data Source=serverName; Initial Catalog=databaseName; User ID=userName; Password=password"
DataProviderString = "AssemblyName={System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}; ConnectionType=System.Data.SqlClient.SqlConnection"
Oracle ConnectionString = "Data Source=tnsName; User ID=schemaUserName; Password=schemaPassword"
DataProviderString = "AssemblyName={Oracle.DataAccess, Version=2.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342}; ConnectionType=Oracle.DataAccess.Client.OracleConnection"
MySQL ConnectionString = "Server=serverName; Database=databaseName; Uid=root; Pwd=password; allow user variables = true"
DataProviderString = "AssemblyName={MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d}; ConnectionType=MySql.Data.MySqlClient.MySqlConnection"
SQLite ConnectionString = "Data Source=databaseName.db; Version=3; Foreign Keys=True; FailIfMissing=True"
DataProviderString = "AssemblyName={System.Data.SQLite, Version=1.0.109.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139}; ConnectionType=System.Data.SQLite.SQLiteConnection"
SQLite (Mono native driver) ConnectionString = "Data Source=./databaseName.db; Version=3; Foreign Keys=True; FailIfMissing=True"
DataProviderString = "AssemblyName={Mono.Data.Sqlite, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756}; ConnectionType=Mono.Data.Sqlite.SqliteConnection"
Access / OleDB ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=databaseName.mdb"
DataProviderString = "AssemblyName={System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}; ConnectionType=System.Data.OleDb.OleDbConnection"
ODBC Connection ConnectionString = "Driver={SQL Server Native Client 10.0}; Server=serverName; Database=databaseName; Uid=userName; Pwd=password"
DataProviderString = "AssemblyName={System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}; ConnectionType=System.Data.Odbc.OdbcConnection"
Example configuration file that defines connection settings:
C#
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="categorizedSettings" type="GSF.Configuration.CategorizedSettingsSection, GSF.Core" />
  </configSections>
  <categorizedSettings>
    <systemSettings>
      <add name="ConnectionString" value="Data Source=localhost\SQLEXPRESS; Initial Catalog=MyDatabase; Integrated Security=SSPI" description="ADO database connection string" encrypted="false" />
      <add name="DataProviderString" value="AssemblyName={System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}; ConnectionType=System.Data.SqlClient.SqlConnection" description="ADO database provider string" encrypted="false" />
    </systemSettings>
  </categorizedSettings>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
</configuration>

Constructors

AdoDataConnection(IDbConnection, Boolean) Creates a new AdoDataConnection from specified connection.
AdoDataConnection(String, String) Creates and opens a new AdoDataConnection from specified connectionString and dataProviderString.
AdoDataConnection(String, Type) Creates and opens a new AdoDataConnection from specified connectionString and connectionType.

Properties

Connection Gets an open IDbConnection to configured ADO.NET data source.
DatabaseType Gets or sets the type of the database underlying the AdoDataConnection.
DefaultIsolationLevel Gets the default IsolationLevel for the connected AdoDataConnection database type.
DefaultTimeout Gets or sets default timeout for AdoDataConnection data operations.
IsJetEngine Gets a value to indicate whether source database is Microsoft Access.
IsMySQL Gets a value to indicate whether source database is MySQL.
IsOracle Gets a value to indicate whether source database is Oracle.
IsPostgreSQL Gets a value to indicate whether source database is PostgreSQL.
IsSqlite Gets a value to indicate whether source database is SQLite.
IsSQLServer Gets a value to indicate whether source database is Microsoft SQL Server.
UtcNow Gets current UTC date-time in an implementation that is proper for the connected AdoDataConnection database type.

Methods

Bool Returns proper Boolean implementation for connected AdoDataConnection database type.
Dispose Releases all the resources used by the AdoDataConnection object.
Dispose(Boolean) Releases the unmanaged resources used by the AdoDataConnection object and optionally releases the managed resources.
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
EscapeIdentifier Escapes an identifier, e.g., a table or field name, using the common delimiter for the connected AdoDataConnection database type or the standard ANSI escaping delimiter, i.e., double-quotes, based on the useAnsiQuotes flag.
ExecuteNonQuery(String, Object) Executes the SQL statement using Connection, and returns the number of rows affected.
ExecuteNonQuery(Int32, String, Object) Executes the SQL statement using Connection, and returns the number of rows affected.
ExecuteReader(String, Object) Executes the SQL statement using Connection, and builds a IDataReader.
ExecuteReader(Int32, String, Object) Executes the SQL statement using Connection, and builds a IDataReader.
ExecuteReader(CommandBehavior, Int32, String, Object) Executes the SQL statement using Connection, and builds a IDataReader.
ExecuteScalar(String, Object) Executes the SQL statement using Connection, and returns the value in the first column of the first row in the result set.
ExecuteScalar(Int32, String, Object) Executes the SQL statement using Connection, and returns the value in the first column of the first row in the result set.
ExecuteScalar(Type, String, Object) Executes the SQL statement using Connection, and returns the value in the first column of the first row in the result set as type returnType.
ExecuteScalar(Type, Int32, String, Object) Executes the SQL statement using Connection, and returns the value in the first column of the first row in the result set as type returnType.
ExecuteScalar(Type, Object, String, Object) Executes the SQL statement using Connection, and returns the value in the first column of the first row in the result set as type returnType, substituting defaultValue if Value is retrieved.
ExecuteScalar(Type, Object, Int32, String, Object) Executes the SQL statement using Connection, and returns the value in the first column of the first row in the result set as type returnType, substituting defaultValue if Value is retrieved.
ExecuteScalarT(String, Object) Executes the SQL statement using Connection, and returns the value in the first column of the first row in the result set as type T.
ExecuteScalarT(Int32, String, Object) Executes the SQL statement using Connection, and returns the value in the first column of the first row in the result set as type T.
ExecuteScalarT(T, String, Object) Executes the SQL statement using Connection, and returns the value in the first column of the first row in the result set as type T, substituting defaultValue if Value is retrieved.
ExecuteScalarT(T, Int32, String, Object) Executes the SQL statement using Connection, and returns the value in the first column of the first row in the result set as type T, substituting defaultValue if Value is retrieved.
ExecuteScript(String) Executes the given SQL script using Connection.
ExecuteScript(TextReader) Executes the given SQL script using Connection.
Finalize Releases the unmanaged resources before the AdoDataConnection object is reclaimed by GC.
(Overrides ObjectFinalize)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
Guid(Guid) Returns proper Guid implementation for connected AdoDataConnection database type.
Guid(DataRow, String) Retrieves Guid from a DataRow field based on database type.
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
ParameterizedQueryString Creates a parameterized query string for the underlying database type based on the given format string and parameter names.
RetrieveData(String, Object) Executes the SQL statement using Connection, and returns the first DataTable of result set, if the result set contains at least one table.
RetrieveData(Int32, String, Object) Executes the SQL statement using Connection, and returns the first DataTable of result set, if the result set contains at least one table.
RetrieveDataSet(String, Object) Executes the SQL statement using Connection, and returns the DataSet that may contain multiple tables, depending on the SQL statement.
RetrieveDataSet(Int32, String, Object) Executes the SQL statement using Connection, and returns the DataSet that may contain multiple tables, depending on the SQL statement.
RetrieveRow(String, Object) Executes the SQL statement using Connection, and returns the first DataRow in the result set.
RetrieveRow(Int32, String, Object) Executes the SQL statement using Connection, and returns the first DataRow in the result set.
ToDataProviderString Generates a data provider string for the given connection type.
ToStringReturns a string that represents the current object.
(Inherited from Object)

See Also