Table of contents
page
Lesson 01: Introduction to ADO.NET
2
Lesson 02: The SqlConnection Object
6
Lesson 03: The SqlCommand Object
10
Lesson 04: Reading Data with the SqlDataReader
19
Lesson 05: Working with Disconnected Data
25
Lesson 06: Adding Parameters to Commands
33
Lesson 07: Using Stored Procedures
38
Lesson 01: Introduction to ADO.NET 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:
• • • • • • •
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