DekGenius.com
[ Team LiB ] Previous Section Next Section

Chapter 18. The Connection Class

The Connection class is provided by all standard ADO.NET providers and represents a connection between your code and a data source. Connections require resources, so one hallmark of well-written ADO.NET code is that it opens a connection only when necessary and releases it as soon as possible. The Connection class is provided in several provider-specific varieties, including SqlConnection and OleDbConnection.

Most of the Connection properties are informational and can't be modified directly. Instead, before opening a connection, you use the ConnectionString property to set such information as the location of the data source, the authentication credentials, and the connection timeout. The Connection class is also the heart of client-side transactions with ADO.NET, connection pooling, and schema tables with the OLE DB provider.

    [ Team LiB ] Previous Section Next Section