Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 3rd, 2005, 01:45 PM
Registered User
Join Date: Sep 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default looping through columns in sqldatareader

I have retrieved a single row of data using sqldatareader and want to load the value of each column into a session variable. How do I do this in VB.NET? For example this is how I did it in classic ASP. Just can't quite figure out the syntax in VB.NET. Thanks!

For Each strField In UserReader.Item

   strName = strField.Name

   strValue = strField.Value

   Session(strName) = strValue

Old November 5th, 2005, 02:32 AM
Friend of Wrox
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts

You need to use a while loop:

Do While yourdatareader.read()
   strName = yourdatareader.Item("name")
   .. etc. do it for each column

Similar Threads
Thread Thread Starter Forum Replies Last Post
sqldatareader close connection mdonner BOOK: Beginning ASP.NET 1.0 2 July 5th, 2007 04:50 AM
Inheriting SqlDataReader and new KeyWord software_developer_kk C# 2 June 28th, 2007 08:17 AM
SqlDataReader testsubject ADO.NET 9 March 7th, 2006 06:08 PM
Urgent getting Error while using SqlDataReader hums ADO.NET 2 September 29th, 2004 10:03 AM
SelectedValue property using SqlDataReader shiju ADO.NET 0 September 28th, 2003 03:27 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.