asp.net.ph

IDbConnection Interface

System.Data Namespace


Represents an open connection to a data source, and is implemented by .NET data providers that access relational databases.

IDbConnection Interface Members

Collapse   Properties

Visibility Name Value Type Accessibility
public ConnectionString String [ Get , Set ]
public ConnectionTimeout Int32 [ Get ]
public Database String [ Get ]
public State ConnectionState [ Get ]

Collapse   Methods

Visibility Name Parameters Return Type
public BeginTransaction ( IsolationLevel il ) IDbTransaction
public BeginTransaction ( ) IDbTransaction
public ChangeDatabase ( String databaseName ) Void
public Close ( ) Void
public CreateCommand ( ) IDbCommand
public Open ( ) Void

Classes that Implement IDbConnection


Class Description
OleDbConnection Represents an open connection to a data source.
SqlConnection Represents an open connection to an SQL Server™ database. This class cannot be inherited.

Remarks

The IDbConnection interface allows an inheriting class to implement a Connection class, which represents a unique session with a data source ( for example, a network connection to a server ). For more information about Connection classes, see ADO.NET Connections. For more information about implementing .NET data providers, see Implementing a .NET Data Provider.

An application does not create an instance of the IDbConnection interface directly, but initializes an instance of a class that inherits IDbConnection.

Classes that inherit IDbConnection must implement the inherited members, and typically define additional members to add provider-specific functionality. For example, the IDbConnection interface defines the ConnectionTimeout property. In turn, the IDbConnection class inherits this property, and also defines the PacketSize property.

Notes to Implementers: To promote consistency among .NET data providers, name the inheriting class in the form Prv Connection where Prv is the uniform prefix given to all classes in a specific .NET data provider namespace. For example, Sql is the prefix of the IDbConnection class in the System.Data.SqlClient namespace.

When you inherit from the IDbConnection interface, you should implement the following constructors:


Item Description
PrvConnection ( ) Initializes a new instance of the PrvConnection class.
PrvConnection ( string connectionString ) Initializes a new instance of the PrvConnection class when given a string containing the connection string.

Example

The following examples illustrate using instances of SqlConnection and OleDbConnection — classes that derive from IDbConnection — to connect to a data source and display some of its properties.

Connecting to an SQL Server™ Data Source
Run Sample | View Source
Connecting to an OLEDB Data Source
Run Sample | View Source

See Also

Connecting to a Database Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph