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.128 -- Release Build+cb657b646daac3e9cc5384ff42ed4530df50eab1
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=Microsoft.Data.SqlClient; ConnectionType=Microsoft.Data.SqlClient.SqlConnection"
SQLite ConnectionString = "Data Source=databaseName.db; Version=3; Foreign Keys=True; FailIfMissing=True"
DataProviderString = "AssemblyName=Microsoft.Data.Sqlite; ConnectionType=Microsoft.Data.Sqlite.SqliteConnection"
PostgreSQL ConnectionString = "Host=localhost; Database=DatabaseName; Username=postgres; Password=password"
DataProviderString = "AssemblyName=Npgsql; ConnectionType=Npgsql.NpgsqlConnection"
MySQL ConnectionString = "Server=serverName; Database=databaseName; Uid=root; Pwd=password; allow user variables = true"
DataProviderString = "AssemblyName=MySql.Data; ConnectionType=MySql.Data.MySqlClient.MySqlConnection"
Oracle ConnectionString = "Data Source=tnsName; User ID=schemaUserName; Password=schemaPassword"
DataProviderString = "AssemblyName=Oracle.ManagedDataAccess; ConnectionType=Oracle.ManagedDataAccess.Client.OracleConnection"
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(Settings) Creates and opens a new AdoDataConnection from specified settings.
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.
DefineSettings Establishes default settings for the config file.
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