   DbConnection   DbCommand   DbDataReader   DbDataAdapter   DbProviderFactory
   The classes that are responsible for working with the    database for    connecting, retrieving, updating, inserting, ...
   To access a data store, you need a valid, open    connection object.   The DbConnection class is an abstract class fr...
Open Database Connectivity (ODBC) is one of the oldertechnologies that the .NET Framework supports, primarilybecause there...
   Driver={Microsoft Text Driver (*.txt; *.csv)};    DBQ=C:SampleMySampleFolder;   Driver={Microsoft Access Driver (*.md...
Another common, but older, technology that isused to access databases is Object Linking andEmbedding for Databases (OLEDB).
This connection string uses the settings stored in theMyAppData.udl file (the .udl extension stands for universaldata link...
Persist Security Info=False; Integrated Security=SSPI;database=northwind;Network Library=DBMSSOCN;Data Source=192.168.1.5,...
<connectionStrings><add name="PubsData“ providerName="System.Data.SqlClient"connectionString= "Data Source=.SQLEXPRESS;Att...
   Connection pooling is the process of reusing existing active    connections instead of creating new connections when a...
Connection pooling is controlled by parametersplaced into the connection string. The followingis a list of parameters that...
   The DbCommand object is used to send one or more    Structured Query Language (SQL) statements to the    data store. ...
Connected data classes
Connected data classes
Connected data classes
Connected data classes
Upcoming SlideShare
Loading in …5
×

Connected data classes

408 views
376 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
408
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Connected data classes

  1. 1.  DbConnection DbCommand DbDataReader DbDataAdapter DbProviderFactory
  2. 2.  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
  3. 3.  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 hereconnection.Close();
  4. 4. Open Database Connectivity (ODBC) is one of the oldertechnologies that the .NET Framework supports, primarilybecause there are still many scenarios in which the .NETFramework is required to connect to older databaseproducts that have ODBC drivers.
  5. 5.  Driver={Microsoft Text Driver (*.txt; *.csv)}; DBQ=C:SampleMySampleFolder; Driver={Microsoft Access Driver (*.mdb)}; DBQ=C:CodemySampleFoldernorthwind.mdb Driver={Microsoft ODBC for Oracle}; Server=ORACLE8i7; UID=john; PWD=s3$W%1Xz Driver={Microsoft Excel Driver (*.xls)}; DBQ=C:SamplesMyBook.xls DRIVER={SQL Server}; SERVER=MyServer; UID=AppUserAccount; PWD=Zx%7$ha; DATABASE=northwind;
  6. 6. Another common, but older, technology that isused to access databases is Object Linking andEmbedding for Databases (OLEDB).
  7. 7. This connection string uses the settings stored in theMyAppData.udl file (the .udl extension stands for universaldata link):FILE NAME=C:Program FilesMyAppMyAppData.udlThis connection string uses the Jet driver, which is theAccess driver, and opens the demo.mdb database file.Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Program FilesmyAppdemo.mdb;Persist Security Info=False
  8. 8. 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@1Data Source=.SQLEXPRESS;AttachDbFilename=C:MyApplicationPUBS.MDF;Integrated Security=True; User Instance=True
  9. 9. <connectionStrings><add name="PubsData“ providerName="System.Data.SqlClient"connectionString= "Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|PUBS.MDF; IntegratedSecurity=True; User Instance=True"/></connectionStrings>ConnectionStringSettings pubs =ConfigurationManager.ConnectionStrings["PubsData"];DbConnection connection = new SqlConnection(pubs.ConnectionString);
  10. 10.  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.
  11. 11. Connection pooling is controlled by parametersplaced into the connection string. The followingis a list of parameters that affect pooling: Connection Timeout Min Pool Size Max Pool Size Pooling Connection Reset Load Balancing Timeout, Connection Lifetime Enlist
  12. 12.  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

×