ADO.NET 101: SqlDataReader
(Page 1 of 7 )
Have you ever wanted to learn more about the functionality of the SQLDataReader? This article, the first in a series, focuses mainly on the SQLDataReader, and also covers the ExecuteReader() and the ExecuteXMLReader() execute methods of SQLCommand.
This tutorial deals only with the SQLDataReader object. As the SQLDataReader is inherently bound to the SQLCommand object, SQLCommand object is also discussed. SQLCommand object by itself will be discussed in a future tutorial.
Code for all of the examples is initiated by a button click event, and data display is mostly accomplished by being written to the browser. Sometimes a list box or a text box may be used for parameter entry, or display data; otherwise, there are no other GUIs. The databases are example databases that are commonly found on a SQL Server. The only changes needed for the connection information are the database server name, the database name, and authentication. In the case of SQL authentication, the User ID and Password must be included.
The Stored Procedures can be created by pasting the code in the Query Analyzer when the proper database is chosen. Since stored procedures are executed, additonal permissions have to be set up for the stored procedures after they are created. This can be carried out easily in the Enterprise Manager.
SQLConnection
Before one can get to the SQLCommand, one needs to connect to the SQL Server. This is accomplished by using the SQLConnection. SQLConnection can be made using built-in GU interface or code, and in either case the correct connection string must be specified. This has been dealt with in considerable detail elsewhere(http://www.codeproject.com/aspnet/SQLConnect.asp).
Next: SQLDataReader Class >>
More Database Articles
More By Jayaram Krishnaswamy