<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Nannette Thacker ShiningStar.net : DataReader</title><link>http://weblogs.asp.net/nannettethacker/archive/tags/DataReader/default.aspx</link><description>Tags: DataReader</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Section 9: C# and VB Project: Using our TableAdapters, DataTables and Intellisense</title><link>http://weblogs.asp.net/nannettethacker/archive/2008/09/09/section-9-c-and-vb-project-using-our-tableadapters-datatables-and-intellisense.aspx</link><pubDate>Tue, 09 Sep 2008 13:19:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6600313</guid><dc:creator>nannette</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/nannettethacker/rsscomments.aspx?PostID=6600313</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/nannettethacker/commentapi.aspx?PostID=6600313</wfw:comment><comments>http://weblogs.asp.net/nannettethacker/archive/2008/09/09/section-9-c-and-vb-project-using-our-tableadapters-datatables-and-intellisense.aspx#comments</comments><description>&lt;P mce_keep="true"&gt;In our final &lt;A href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject9.aspx" target=_blank&gt;Section 9&lt;/A&gt; of this tutorial by Nannette Thacker, we learn how to use our TableAdapters within our code. We also look at how Intellisense makes it easy to set up your TableAdapter code. &lt;BR&gt;&lt;BR&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink5 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject.aspx"&gt;Introduction: C# and VB Project: A Tutorial Using Data Sets, Table Adapters, WebForms, Controls, File Upload, Excel Import&lt;/A&gt; 
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink1 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject1.aspx"&gt;Section 1: Creating Our Project, Database and Tables&lt;/A&gt; 
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink2 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject2.aspx"&gt;Section 2: WebForm: Table, Label, and Panel Controls&lt;/A&gt; 
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink3 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject3.aspx"&gt;Section 3: FileUpload Control and Functionality&lt;/A&gt; 
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink4 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject4.aspx"&gt;Section 4: Auto Formatting a Web Form GridView&lt;/A&gt; 
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink6 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject5.aspx"&gt;Section 5: Bind the Excel Data to a GridView using an OleDbDataAdapter&lt;/A&gt; 
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink7 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject6.aspx"&gt;Section 6: Data Access Layer DataSet TableAdapters&lt;/A&gt; 
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink8 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject7.aspx"&gt;Section 7: TableAdapter Select and Insert Queries with Parameters&lt;/A&gt; 
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink9 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject8.aspx"&gt;Section 8: Using an OleDbDataReader to Retrieve Our Data&lt;/A&gt; 
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink10 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject9.aspx"&gt;Section 9: Using our TableAdapters, DataTables and Intellisense&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;Download the ZIP files:&lt;BR&gt;&lt;A href="http://weblogs.asp.net/blogs/nannettethacker/zips/ShiningStarCExcel.zip"&gt;C#: ShiningStarCExcel.zip&lt;/A&gt;&lt;BR&gt;&lt;A href="http://weblogs.asp.net/blogs/nannettethacker/zips/ShiningStarVBExcel.zip"&gt;VB: ShiningStarVBExcel.zip&lt;/A&gt;&lt;BR&gt;&lt;BR&gt;&lt;I&gt;&lt;B&gt;Do everything without complaining or arguing, so that you may become blameless and pure. Philippians 2:14&lt;/B&gt; &lt;/I&gt;&lt;BR&gt;&lt;BR&gt;May your dreams be in ASP.NET! &lt;BR&gt;Nannette Thacker &lt;BR&gt;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6600313" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/DataReader/default.aspx">DataReader</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/DataSets/default.aspx">DataSets</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/TableAdapters/default.aspx">TableAdapters</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/Visual+Web+Developer/default.aspx">Visual Web Developer</category></item><item><title>Section 8: C# and VB Project: Using an OleDbDataReader to Retrieve Our Data</title><link>http://weblogs.asp.net/nannettethacker/archive/2008/09/08/section-8-c-and-vb-project-using-an-oledbdatareader-to-retrieve-our-data.aspx</link><pubDate>Mon, 08 Sep 2008 20:16:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6600306</guid><dc:creator>nannette</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/nannettethacker/rsscomments.aspx?PostID=6600306</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/nannettethacker/commentapi.aspx?PostID=6600306</wfw:comment><comments>http://weblogs.asp.net/nannettethacker/archive/2008/09/08/section-8-c-and-vb-project-using-an-oledbdatareader-to-retrieve-our-data.aspx#comments</comments><description>&lt;P mce_keep="true"&gt;In &lt;A href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject8.aspx" target=_blank&gt;Section 8&lt;/A&gt; of this tutorial by Nannette Thacker, we take a look at adding a OleDbDataReader and the ExecuteReader method to retrieve data from an Excel Spreadsheet. &lt;BR&gt;&lt;BR&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink5 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject.aspx"&gt;Introduction: C# and VB Project: A Tutorial Using Data Sets, Table Adapters, WebForms, Controls, File Upload, Excel Import&lt;/A&gt; 
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink1 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject1.aspx"&gt;Section 1: Creating Our Project, Database and Tables&lt;/A&gt; 
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink2 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject2.aspx"&gt;Section 2: WebForm: Table, Label, and Panel Controls&lt;/A&gt; 
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink3 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject3.aspx"&gt;Section 3: FileUpload Control and Functionality&lt;/A&gt; 
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink4 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject4.aspx"&gt;Section 4: Auto Formatting a Web Form GridView&lt;/A&gt; 
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink6 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject5.aspx"&gt;Section 5: Bind the Excel Data to a GridView using an OleDbDataAdapter&lt;/A&gt; 
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink7 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject6.aspx"&gt;Section 6: Data Access Layer DataSet TableAdapters&lt;/A&gt; 
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink8 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject7.aspx"&gt;Section 7: TableAdapter Select and Insert Queries with Parameters&lt;/A&gt; 
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink9 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject8.aspx"&gt;Section 8: Using an OleDbDataReader to Retrieve Our Data&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;Download the ZIP files:&lt;BR&gt;&lt;A href="http://weblogs.asp.net/blogs/nannettethacker/zips/ShiningStarCExcel.zip"&gt;C#: ShiningStarCExcel.zip&lt;/A&gt;&lt;BR&gt;&lt;A href="http://weblogs.asp.net/blogs/nannettethacker/zips/ShiningStarVBExcel.zip"&gt;VB: ShiningStarVBExcel.zip&lt;/A&gt;&lt;BR&gt;&lt;BR&gt;&lt;I&gt;&lt;B&gt;"Taste and see that the LORD is good; blessed is the man who takes refuge in him." Psalm 34:8&lt;/B&gt; &lt;/I&gt;&lt;BR&gt;&lt;BR&gt;May your dreams be in ASP.NET! &lt;BR&gt;Nannette Thacker &lt;BR&gt;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6600306" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/DataReader/default.aspx">DataReader</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/DataSets/default.aspx">DataSets</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/TableAdapters/default.aspx">TableAdapters</category></item><item><title>C# and VB Project: A Tutorial Using Data Sets, Table Adapters, WebForms, Controls, File Upload, Excel Import</title><link>http://weblogs.asp.net/nannettethacker/archive/2008/08/13/c-and-vb-project-a-tutorial-using-data-sets-table-adapters-webforms-controls-file-upload-excel-import.aspx</link><pubDate>Wed, 13 Aug 2008 15:35:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6503708</guid><dc:creator>nannette</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/nannettethacker/rsscomments.aspx?PostID=6503708</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/nannettethacker/commentapi.aspx?PostID=6503708</wfw:comment><comments>http://weblogs.asp.net/nannettethacker/archive/2008/08/13/c-and-vb-project-a-tutorial-using-data-sets-table-adapters-webforms-controls-file-upload-excel-import.aspx#comments</comments><description>&lt;P mce_keep="true"&gt;In this &lt;A href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject.aspx" target=_blank mce_href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject.aspx"&gt;tutorial&lt;/A&gt; by Nannette Thacker, we will create a VB or C# project from scratch. We will create DataSets, TableAdapters, a WebForm and Controls, a File Upload, and import and view an Excel Spreadsheet, and more! We'll also learn about intellisense and other features of Visual Studio or Visual Web Developer. This project may be used in both VS or VWD 2005 or 2008. Zip files with the complete source code in either C# or VB, Excel Spreadsheet, and .mdf SQL Server Database is available for download. You may easily modify this tutorial to use an existing database as well. &lt;BR&gt;&lt;BR&gt;I have written this tutorial with step by step instructions and screen shots on how to do each point. If you are learning ASP.NET, please don't simply download the source code and plunk it into your project, the best way to learn is to walk through the tutorial from scratch and do each step yourself. &lt;BR&gt;&lt;BR&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A id=ctl00_ContentPlaceHolder1_HyperLink5 href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject.aspx" mce_href="http://www.shiningstar.net/ASPNet_Articles/DataSet/DataSetProject.aspx"&gt;Introduction: C# and VB Project: A Tutorial Using Data Sets, Table Adapters, WebForms, Controls, File Upload, Excel Import&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;Download the ZIP files:&lt;BR&gt;&lt;A href="http://weblogs.asp.net/blogs/nannettethacker/zips/ShiningStarCExcel.zip" mce_href="http://weblogs.asp.net/blogs/nannettethacker/zips/ShiningStarCExcel.zip"&gt;C#: ShiningStarCExcel.zip&lt;/A&gt;&lt;BR&gt;&lt;A href="http://weblogs.asp.net/blogs/nannettethacker/zips/ShiningStarVBExcel.zip" mce_href="http://weblogs.asp.net/blogs/nannettethacker/zips/ShiningStarVBExcel.zip"&gt;VB: ShiningStarVBExcel.zip&lt;/A&gt;&lt;BR&gt;&lt;BR&gt;&lt;I&gt;Learning a new technology can be intimidating when first starting out. You want to learn it in 5 minutes, and in some cases, you feel pressured that you must learn it in 5 minutes! I remember first learning C programming in college years ago, and lying on the bedroom floor in tears, crying and pleading with God to teach me. I felt I was struggling, but through His grace, He helped me earn one of only two A's in the course which had over 100 students. &lt;BR&gt;&lt;BR&gt;I encourage you, don't give up, and pray for God's help. He will be there for you, as long as your project is one that is not contrary to His will. &lt;BR&gt;&lt;BR&gt;&lt;B&gt;I can do all things through Christ who strengthens me. Philippians 4:13&lt;/B&gt; &lt;/I&gt;&lt;BR&gt;&lt;BR&gt;May your dreams be in ASP.NET! &lt;BR&gt;Nannette Thacker &lt;BR&gt;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6503708" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/Cascading+Style+Sheets/default.aspx">Cascading Style Sheets</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/CSS/default.aspx">CSS</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/DataReader/default.aspx">DataReader</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/DataSets/default.aspx">DataSets</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/Excel/default.aspx">Excel</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/Visual+Web+Developer/default.aspx">Visual Web Developer</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/Web+Forms/default.aspx">Web Forms</category></item><item><title>Importing an Excel Spreadsheet Using Typed DataSets and TableAdapters: Importing the Excel Spreadsheet</title><link>http://weblogs.asp.net/nannettethacker/archive/2008/08/11/importing-an-excel-spreadsheet-using-typed-datasets-and-tableadapters-importing-the-excel-spreadsheet.aspx</link><pubDate>Mon, 11 Aug 2008 16:07:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6502001</guid><dc:creator>nannette</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/nannettethacker/rsscomments.aspx?PostID=6502001</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/nannettethacker/commentapi.aspx?PostID=6502001</wfw:comment><comments>http://weblogs.asp.net/nannettethacker/archive/2008/08/11/importing-an-excel-spreadsheet-using-typed-datasets-and-tableadapters-importing-the-excel-spreadsheet.aspx#comments</comments><description>&lt;P mce_keep="true"&gt;&lt;EM&gt;By Nannette Thacker&lt;BR&gt;&lt;BR&gt;&lt;/EM&gt;In the final installment of this tutorial, we look at importing the uploaded Excel spreadsheet into the application database tables using the DAL. &lt;BR&gt;&lt;BR&gt;The article series hosted on 4guysfromrolla.com continues with &lt;A href="http://aspnet.4guysfromrolla.com/articles/032608-1.aspx" target=_blank&gt;Importing an Excel Spreadsheet Using Typed DataSets and TableAdapters: Importing the Excel Spreadsheet&lt;/A&gt;. &lt;BR&gt;&lt;BR&gt;&lt;A href="http://aspnet.4guysfromrolla.com/code/NannetteExcelDAL.zip" target=_blank&gt;Download the Application&lt;/A&gt; in ZIP Format &lt;BR&gt;&lt;BR&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://aspnet.4guysfromrolla.com/articles/031208-1.aspx" target=_blank&gt;Importing an Excel Spreadsheet Using Typed DataSets and TableAdapters: Displaying the Uploaded Excel Spreadsheet&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://aspnet.4guysfromrolla.com/articles/030508-1.aspx" target=_blank&gt;Importing an Excel Spreadsheet Using Typed DataSets and TableAdapters: Building the Importer Web Page and Uploading the Excel Spreadsheet&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://aspnet.4guysfromrolla.com/articles/022708-1.aspx" target=_blank&gt;Importing an Excel Spreadsheet Using Typed DataSets and TableAdapters: Building the Database&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://aspnet.4guysfromrolla.com/articles/031908-1.aspx" target=_blank&gt;Importing an Excel Spreadsheet Using Typed DataSets and TableAdapters: Creating a Data Access Layer (DAL)&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://aspnet.4guysfromrolla.com/articles/032608-1.aspx" target=_blank&gt;Importing an Excel Spreadsheet Using Typed DataSets and TableAdapters: Importing the Excel Spreadsheet&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&lt;BR&gt;May your dreams be in ASP.NET! &lt;BR&gt;&lt;BR&gt;Nannette Thacker &lt;BR&gt;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6502001" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/DataReader/default.aspx">DataReader</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/DataSets/default.aspx">DataSets</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/Excel/default.aspx">Excel</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/TableAdapters/default.aspx">TableAdapters</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>Retrieving Values from a DataReader</title><link>http://weblogs.asp.net/nannettethacker/archive/2008/02/14/retrieving-values-from-a-datareader.aspx</link><pubDate>Thu, 14 Feb 2008 17:57:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:5770602</guid><dc:creator>nannette</dc:creator><slash:comments>15</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/nannettethacker/rsscomments.aspx?PostID=5770602</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/nannettethacker/commentapi.aspx?PostID=5770602</wfw:comment><comments>http://weblogs.asp.net/nannettethacker/archive/2008/02/14/retrieving-values-from-a-datareader.aspx#comments</comments><description>&lt;DIV id=kick&gt;&lt;EM&gt;By Nannette Thacker&lt;BR&gt;&lt;BR&gt;&lt;/EM&gt;There are several ways to retrieve values from a DataReader. &lt;BR&gt;&lt;BR&gt;The first method is by using the index and looping through the fields in order as retrieved within the Select statement. Starting with the 0 index, you may use the GetValue() Function. &lt;BR&gt;&lt;BR&gt;The following code snippets are in VB. A C# snippet is provided at the bottom. &lt;BR&gt;&lt;BR&gt;&lt;PRE&gt;reader = objCommand.ExecuteReader()
While reader.Read()

If Not reader.GetValue(0) Is DBNull.Value Then _
    lastname = reader.GetValue(0)
If Not reader.GetValue(1) Is DBNull.Value Then _
    firstname = reader.GetValue(1)

End While
reader.Close()&lt;/PRE&gt;However, this makes the code harder to read, and if a field is added or removed from the query, it could break your code. So let's look at how to retrieve the values by field names. &lt;BR&gt;&lt;BR&gt;If your reader is using an OleDbDataReader, we use the reader.Item function. &lt;BR&gt;&lt;BR&gt;&lt;PRE&gt;If Not reader.Item("lastname") Is DBNull.Value Then _
    lastname = reader.Item("lastname")
If Not reader.Item("firstname") Is DBNull.Value Then _
    firstname = reader.Item("firstname")&lt;/PRE&gt;If your reader is using a SqlDataReader, we use the reader.GetItem function. &lt;BR&gt;&lt;BR&gt;&lt;PRE&gt;If Not reader.GetItem("lastname") Is DBNull.Value Then _
    lastname = reader.GetItem("lastname")
If Not reader.GetItem("firstname") Is DBNull.Value Then _
    firstname = reader.GetItem("firstname")&lt;/PRE&gt;Here is a C# example: &lt;BR&gt;&lt;BR&gt;&lt;PRE&gt;if (reader["lastname"] != DBNull.Value)
    lastname = reader["lastname"].ToString();&lt;/PRE&gt;A reader of my column, Zac, suggests that reader("lastname") instead of reader.Item("lastname") will also work. &lt;BR&gt;&lt;BR&gt;He is correct. For the DataReader class implementation, Item is the default property and may be left out. You may access an indexer by using the () operator on the base class object or you may access an indexer by using the Item property. &lt;BR&gt;&lt;BR&gt;Another reader of my column, Marneus, pointed out the GetOrdinal option as well. He said "there is a performance hit, each time you use the reader("lastname"), it has to check the meta datas to get the column number." &lt;BR&gt;&lt;BR&gt;Readers may refer to this document on the GetOrdinal() &lt;BR&gt;&lt;BR&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.getordinal.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.getordinal.aspx"&gt;http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.getordinal.aspx&lt;/A&gt; &lt;BR&gt;&lt;BR&gt;Please note this comment on efficiency: &lt;BR&gt;&lt;BR&gt;"Because ordinal-based lookups are more efficient than named lookups, it is inefficient to call GetOrdinal within a loop. Save time by calling GetOrdinal once and assigning the results to an integer variable for use within the loop." &lt;BR&gt;&lt;BR&gt;From the article, here is the usage: &lt;BR&gt;&lt;BR&gt;&lt;PRE&gt;' Call GetOrdinal and assign value to variable.
Dim customerID As Integer = reader.GetOrdinal("CustomerID")

' Use variable with GetString inside of loop.
While reader.Read()
    Console.WriteLine("CustomerID={0}", reader.GetString(customerID))
End While&lt;/PRE&gt;Another reader, AndrewSeven, pointed out the cost for hitting the reader twice for each field. He suggests: &lt;BR&gt;&lt;BR&gt;&lt;PRE&gt;object val = reader["lastname"];
if (val != DBNull.Value)
{
   lastname = val;
}&lt;/PRE&gt;And also comments "If your concern is readability, you should probably encapsulate the null test so you can write: &lt;BR&gt;&lt;BR&gt;&lt;PRE&gt;lastname = GetValueFromReader(reader,"lastname");"&lt;/PRE&gt;Travis responded with this suggestion: "Just do this, it handles nulls nicely unlike .ToString():" &lt;BR&gt;&lt;BR&gt;&lt;PRE&gt;lastname = Convert.ToString(reader["lastname"]);&lt;/PRE&gt;So I tested his theory by creating columns that would not allow null values, and imported columns with null values. In VB it is written like so: &lt;BR&gt;&lt;BR&gt;&lt;PRE&gt;lastname = Convert.ToString(reader("lastname"))
firstname = Convert.ToString(reader("firstname"))&lt;/PRE&gt;That is much cleaner! Thanks everyone for your great input! &lt;BR&gt;&lt;BR&gt;May your dreams be in ASP.net!&lt;BR&gt;&lt;BR&gt;Nannette Thacker&lt;BR&gt;&lt;/DIV&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5770602" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/DataReader/default.aspx">DataReader</category><category domain="http://weblogs.asp.net/nannettethacker/archive/tags/SQL+Server/default.aspx">SQL Server</category></item></channel></rss>