This lesson is an introduction to ADO.NET. It introduces primary ADO.NET concepts and objects that you will learn about in later lessons. Here are the objectives of this lesson:
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, just to name a few. To further refine the scope of this tutorial, all of the examples will use SQL Server.
You can download the Microsoft SQL Server 2000 Desktop Engine (MSDE 2000) here:
http://www.microsoft.com/sql/msde/downloads/download.asp
MSDE contains documentation on how to perform an installation. However, for your convenience, here are quick instructions on how to install MSDE:
http://www.asp.net/msde/default.aspx?tabindex=0&tabid=1
MSDE 2000 is a scaled down version of SQL Server. Therefore, everything you learn in this tutorial and all code will work with SQL Server. The examples will use the Northwind database. This is a tutorial is specifically for ADO.NET. MSDE is not part of ADO.NET, but it is one of the many data sources you can interact with by using ADO.NET If you need help with MSDE 2000, I refer you to the Microsoft Web site, where you can find pertinent information on licensing and technical assistance:
http://www.microsoft.com/sql/msde/
ADO.NET provides a relatively common way to interact with data sources, but comes in different sets of libraries for each way you can talk to a data source. These libraries are called Data Providers and are usually named for the protocol or data source type they allow you to interact with. Table 1 lists some well known data providers, the API prefix they use, and the type of data source they allow you to interact with.
An example may help you to understand the meaning of the API prefix. One of the first ADO.NET objects you'll learn about is the connection object, which allows you to establish a connection to a data source. If we were using the OleDb Data Provider to connect to a data source that exposes an OleDb interface, we would use a connection object named OleDbConnection. Similarly, the connection object name would be prefixed with Odbc or Sql for an OdbcConnection object on an Odbc data source or a SqlConnection object on a SQL Server database, respectively. Since we are using MSDE in this tutorial (a scaled down version of SQL Server) all the API objects will have the Sql prefix. i.e. SqlConnection.
- Learn what ADO.NET is.
- Understand what a data provider is.
- Understand what a connection object is.
- Understand what a command object is.
- Understand what a DataReader object is.
- Understand what a DataSet object is.
- Understand what a DataAdapter object is.
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. For the purposes of this tutorial, we will look at ADO.NET as a way to interact with a data base.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, just to name a few. To further refine the scope of this tutorial, all of the examples will use SQL Server.
You can download the Microsoft SQL Server 2000 Desktop Engine (MSDE 2000) here:
http://www.microsoft.com/sql/msde/downloads/download.asp
MSDE contains documentation on how to perform an installation. However, for your convenience, here are quick instructions on how to install MSDE:
http://www.asp.net/msde/default.aspx?tabindex=0&tabid=1
MSDE 2000 is a scaled down version of SQL Server. Therefore, everything you learn in this tutorial and all code will work with SQL Server. The examples will use the Northwind database. This is a tutorial is specifically for ADO.NET. MSDE is not part of ADO.NET, but it is one of the many data sources you can interact with by using ADO.NET If you need help with MSDE 2000, I refer you to the Microsoft Web site, where you can find pertinent information on licensing and technical assistance:
http://www.microsoft.com/sql/msde/
Data Providers
We know that 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 for each way you can talk to a data source. These libraries are called Data Providers and are usually named for the protocol or data source type they allow you to interact with. Table 1 lists some well known data providers, the API prefix they use, and the type of data source they allow you to interact with.
Table 1. ADO.NET Data Providers are class libraries that allow a common way to interact with specific data sources or protocols. The library APIs have prefixes that indicate which provider they support.
Provider Name | API prefix | Data Source Description |
---|---|---|
ODBC Data Provider | Odbc | Data Sources with an ODBC interface. Normally older data bases. |
OleDb Data Provider | OleDb | Data Sources that expose an OleDb interface, i.e. Access or Excel. |
Oracle Data Provider | Oracle | For Oracle Databases. |
SQL Data Provider | Sql | For interacting with Microsoft SQL Server. |
Borland Data Provider | Bdp | Generic access to many databases such as Interbase, SQL Server, IBM DB2, and Oracle. |
No comments:
Post a Comment