SlideShare uma empresa Scribd logo
1 de 16
   DbConnection
   DbCommand
   DbDataReader
   DbDataAdapter
   DbProviderFactory
   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
   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();
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.
   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;
Another common, but older, technology that is
used to access databases is Object Linking and
Embedding for Databases (OLEDB).
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
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
<connectionStrings>
<add name="PubsData“ providerName="System.Data.SqlClient"
connectionString= "Data Source=.SQLEXPRESS;
AttachDbFilename=|DataDirectory|PUBS.MDF; Integrated
Security=True; User Instance=True"/>
</connectionStrings>

ConnectionStringSettings pubs =
ConfigurationManager.ConnectionStrings["PubsData"];
DbConnection connection = new SqlConnection(pubs.ConnectionString);
   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.
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
   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

Mais conteúdo relacionado

Mais procurados (20)

Ado.net
Ado.netAdo.net
Ado.net
 
ReactJS
ReactJSReactJS
ReactJS
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
ADO .Net
ADO .Net ADO .Net
ADO .Net
 
Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.net
 
ADO CONTROLS - Database usage
ADO CONTROLS - Database usageADO CONTROLS - Database usage
ADO CONTROLS - Database usage
 
Ado.net
Ado.netAdo.net
Ado.net
 
ADO.NET -database connection
ADO.NET -database connectionADO.NET -database connection
ADO.NET -database connection
 
Ado.Net Architecture
Ado.Net ArchitectureAdo.Net Architecture
Ado.Net Architecture
 
ADO.NET by ASP.NET Development Company in india
ADO.NET by ASP.NET  Development Company in indiaADO.NET by ASP.NET  Development Company in india
ADO.NET by ASP.NET Development Company in india
 
Chap14 ado.net
Chap14 ado.netChap14 ado.net
Chap14 ado.net
 
Introduction to ADO.NET
Introduction to ADO.NETIntroduction to ADO.NET
Introduction to ADO.NET
 
Vb.net session 05
Vb.net session 05Vb.net session 05
Vb.net session 05
 
Ado.Net Tutorial
Ado.Net TutorialAdo.Net Tutorial
Ado.Net Tutorial
 
Ado.net &amp; data persistence frameworks
Ado.net &amp; data persistence frameworksAdo.net &amp; data persistence frameworks
Ado.net &amp; data persistence frameworks
 
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentals
 
Data base connectivity and flex grid in vb
Data base connectivity and flex grid in vbData base connectivity and flex grid in vb
Data base connectivity and flex grid in vb
 
For Beginers - ADO.Net
For Beginers - ADO.NetFor Beginers - ADO.Net
For Beginers - ADO.Net
 
Database connectivity to sql server asp.net
Database connectivity to sql server asp.netDatabase connectivity to sql server asp.net
Database connectivity to sql server asp.net
 
Ch 7 data binding
Ch 7 data bindingCh 7 data binding
Ch 7 data binding
 

Destaque (19)

Blood group
Blood groupBlood group
Blood group
 
Chapter 5 notes
Chapter 5 notesChapter 5 notes
Chapter 5 notes
 
Working with xml data
Working with xml dataWorking with xml data
Working with xml data
 
Come sfruttare la Procedural Content Generation - Presentazione svilupparty 2014
Come sfruttare la Procedural Content Generation - Presentazione svilupparty 2014Come sfruttare la Procedural Content Generation - Presentazione svilupparty 2014
Come sfruttare la Procedural Content Generation - Presentazione svilupparty 2014
 
Web services
Web servicesWeb services
Web services
 
Deploying configuring caching
Deploying configuring cachingDeploying configuring caching
Deploying configuring caching
 
Introducing asp
Introducing aspIntroducing asp
Introducing asp
 
Profile
ProfileProfile
Profile
 
Mobile application
Mobile applicationMobile application
Mobile application
 
User controls
User controlsUser controls
User controls
 
Programming web application
Programming web applicationProgramming web application
Programming web application
 
Monitoring, troubleshooting,
Monitoring, troubleshooting,Monitoring, troubleshooting,
Monitoring, troubleshooting,
 
Custom controls
Custom controlsCustom controls
Custom controls
 
Globalization and accessibility
Globalization and accessibilityGlobalization and accessibility
Globalization and accessibility
 
1 blood basic facts final
1 blood basic facts final1 blood basic facts final
1 blood basic facts final
 
Disconnected data
Disconnected dataDisconnected data
Disconnected data
 
Intelligent exercise selection for posture and health.
Intelligent exercise selection for posture and health. Intelligent exercise selection for posture and health.
Intelligent exercise selection for posture and health.
 
Chapter 8 notes
Chapter 8 notesChapter 8 notes
Chapter 8 notes
 
Hemoglobin & its functions plasma
Hemoglobin & its  functions plasmaHemoglobin & its  functions plasma
Hemoglobin & its functions plasma
 

Semelhante a Connected data classes

Semelhante a Connected data classes (20)

6 database
6 database 6 database
6 database
 
Introduction to ado
Introduction to adoIntroduction to ado
Introduction to ado
 
Ado dot net complete meterial (1)
Ado dot net complete meterial (1)Ado dot net complete meterial (1)
Ado dot net complete meterial (1)
 
Introduction to ado.net
Introduction to ado.netIntroduction to ado.net
Introduction to ado.net
 
PPT temp.pptx
PPT temp.pptxPPT temp.pptx
PPT temp.pptx
 
Final Database Connectivity in JAVA.ppt
Final Database Connectivity in JAVA.pptFinal Database Connectivity in JAVA.ppt
Final Database Connectivity in JAVA.ppt
 
JDBC.ppt
JDBC.pptJDBC.ppt
JDBC.ppt
 
Ado
AdoAdo
Ado
 
Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database Connectivity
 
Data Access Technologies
Data Access TechnologiesData Access Technologies
Data Access Technologies
 
Ado.net
Ado.netAdo.net
Ado.net
 
Chapter 14
Chapter 14Chapter 14
Chapter 14
 
Mule jdbc
Mule   jdbcMule   jdbc
Mule jdbc
 
Is2215 lecture7 lecturer_ado_intro
Is2215 lecture7 lecturer_ado_introIs2215 lecture7 lecturer_ado_intro
Is2215 lecture7 lecturer_ado_intro
 
Ado.net session05
Ado.net session05Ado.net session05
Ado.net session05
 
Unit4
Unit4Unit4
Unit4
 
Jdbc
JdbcJdbc
Jdbc
 
Jdbc
JdbcJdbc
Jdbc
 
15. session 15 data binding
15. session 15   data binding15. session 15   data binding
15. session 15 data binding
 
15. session 15 data binding
15. session 15   data binding15. session 15   data binding
15. session 15 data binding
 

Último

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

Último (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Connected data classes

  • 1.
  • 2. DbConnection  DbCommand  DbDataReader  DbDataAdapter  DbProviderFactory
  • 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.
  • 7. 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;
  • 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
  • 13. <connectionStrings> <add name="PubsData“ providerName="System.Data.SqlClient" connectionString= "Data Source=.SQLEXPRESS; AttachDbFilename=|DataDirectory|PUBS.MDF; Integrated Security=True; User Instance=True"/> </connectionStrings> ConnectionStringSettings pubs = ConfigurationManager.ConnectionStrings["PubsData"]; DbConnection connection = new SqlConnection(pubs.ConnectionString);
  • 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