3. The classes that are responsible for working with the
database for
connecting, retrieving, updating, inserting, and
deleting data are referred to as provider classes in the
framework.
The ADO.NET libraries contain provider classes, which
are classes that you can use to transfer data between a
data store and the client application.
The Microsoft .NET Framework contains the following
data access providers:
OleDb
Odbc
SqlServer
Oracle
4.
5. To access a data store, you need a valid, open
connection object.
The DbConnection class is an abstract class from
which the provider-specific connection classes
inherit.
To create a connection, you must have a valid
connection string.
DbConnection connection = new SqlConnection();
connection.ConnectionString =
"Server=.;Database=pubs;Trusted_Connection=true";
connection.Open();
//do work here
connection.Close();
6. Open Database Connectivity (ODBC) is one of the older
technologies that the .NET Framework supports, primarily
because there are still many scenarios in which the .NET
Framework is required to connect to older database
products that have ODBC drivers.
8. Another common, but older, technology that is
used to access databases is Object Linking and
Embedding for Databases (OLEDB).
9. This connection string uses the settings stored in the
MyAppData.udl file (the .udl extension stands for universal
data link):
FILE NAME=C:Program FilesMyAppMyAppData.udl
This connection string uses the Jet driver, which is the
Access driver, and opens the demo.mdb database file.
Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=C:Program FilesmyAppdemo.mdb;
Persist Security Info=False
10.
11.
12. Persist Security Info=False; Integrated Security=SSPI;
database=northwind;
Network Library=DBMSSOCN;
Data Source=192.168.1.5,1433; Initial Catalog=MyDbName;
User ID=myUsername; Password= u$2hJq@1
Data Source=.SQLEXPRESS;
AttachDbFilename=C:MyApplicationPUBS.MDF;
Integrated Security=True; User Instance=True
14. Connection pooling is the process of reusing existing active
connections instead of creating new connections when a
request is made to the database.
It involves the use of a connection manager that is responsible
for maintaining a list, or pool, of available connections.
When the connection manager receives a request for a new
connection, it checks its pool for available connections. If a
connection is available, it is returned.
If no connections are available, and the maximum pool size has
not been reached, a new connection is created and returned.
If the maximum pool size has been reached, the connection
request is added to the queue and the next available
connection is returned, as long as the connection timeout has
not been reached.
15. Connection pooling is controlled by parameters
placed into the connection string. The following
is a list of parameters that affect pooling:
Connection Timeout
Min Pool Size
Max Pool Size
Pooling
Connection Reset
Load Balancing Timeout, Connection Lifetime
Enlist
16. The DbCommand object is used to send one or more
Structured Query Language (SQL) statements to the
data store.
The DbCommand can be any of the following types:
Data Manipulation Language (DML) Commands that
retrieve, insert, update, or delete data
Data Definition Language (DDL) Commands that
create tables or other database objects, or modify the
database schema
Data Control Language (DCL) Commands that
grant, deny, or revoke permissions