06-06-2013, 04:14 PM
ADO.NET
ADO.NET.pptx (Size: 587.23 KB / Downloads: 14)
Introduction
ADO.NET is an object-oriented set of libraries that allows you to interact with data sources
Commonly, the data source is a database, but it could also be a text file, an Excel spreadsheet, or an XML file
As you are probably aware, there are many different types of databases available
For example, there is Microsoft SQL Server, Microsoft Access, Oracle, Borland Interbase, and IBM DB2 etc….
Data Providers
ADO.NET allows us to interact with different types of data sources and different types of databases
However, there isn't a single set of classes that allow you to accomplish this universally
Since different data sources expose different protocols, we need a way to communicate with the right data source using the right protocol
Some older data sources use the ODBC protocol
Many newer data sources use the OleDb protocol
And there are more data sources every day that allow you to communicate with them directly through .NET ADO.NET class libraries
ADO.NET provides a relatively common way to interact with data sources, but comes in different sets of libraries
These libraries are called Data Providers and are usually named for the protocol or data source type they allow you to interact with.
The SqlConnection Object
To interact with a database, you must have a connection to it
The connection helps identify the database server, the database name, user name, password, and other parameters that are required for connecting to the data base
A connection object is used by command objects so they will know which database to execute the command on
Using a SqlConnection
The purpose of creating a SqlConnection object is so you can enable other ADO.NET code to work with a database
Other ADO.NET objects, such as a SqlCommand and a SqlDataAdapter take a connection object as a parameter
The sequence of operations occurring in the lifetime of a SqlConnection are as follows
Instantiate the SqlConnection.
Open the connection.
Pass the connection to other ADO.NET objects.
Perform database operations with the other ADO.NET objects.
Close the connection.