Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
| Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To 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
  #1 (permalink)  
Old May 24th, 2007, 02:17 AM
Registered User
 
Join Date: May 2007
Location: Hyderabad, A.P, India.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default iterating through cols. of a recordset

if i have a recordset "s" and I want to iterate through the cols in the rows. My problem is that I dont know how many cols. it has. How do I go about.

do while (not s.eof)
???????????????
s.movenext
loop

  #2 (permalink)  
Old May 24th, 2007, 02:58 AM
Friend of Wrox
Points: 687, Level: 9
Points: 687, Level: 9 Points: 687, Level: 9 Points: 687, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2004
Location: Chennai, Tamilnadu, India.
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
Default

snip.... here

<%
Dim StrStudentID
Dim sRst
Dim fCount

StrStudentID = Request.QueryString("sid")
Set sRst = Conn.Execute("Select * from NewRegistration where studentid = " & CLng(StrStudentId))
fCount = sRst.Fields.Count
For q = 1 to CInt(fCount)-1
%>
<TR><TD><%=sRst.fields(q).Name%></TD><TD><%=sRst.fields(q)%></TD></TR>
<%
Next
%>

Is that you were asking?

With Regards,
Raghavendra Mudugal
  #3 (permalink)  
Old May 24th, 2007, 03:17 AM
Registered User
 
Join Date: May 2007
Location: Hyderabad, A.P, India.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks buddy..
I saw in one of the sites.

MyArray=i.GetRows()
For lnRowCounter = 0 To Ubound(MyArray,2)
 For lnColumnCounter = 0 To Ubound(MyArray,1)
  Response.Write MyArray(lnColumnCounter, lnRowCounter)
Next
Next

*************
but urs is simpler.
Thanks again

  #4 (permalink)  
Old May 24th, 2007, 03:41 AM
Registered User
 
Join Date: May 2007
Location: Hyderabad, A.P, India.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The code runs fine but there is a small change-

for q = 0 to CInt(fCount)-1





Similar Threads
Thread Thread Starter Forum Replies Last Post
Iterating through DropDownBox rsearing ASP.NET 2.0 Basics 8 January 3rd, 2007 04:35 PM
Iterating Fonts Ron Howerton Visual Basic 2005 Basics 9 May 31st, 2006 07:15 PM
Rows and Cols Stuff : MSHFlexGrid davekrunal46 VB How-To 1 December 2nd, 2005 01:21 AM
Comparing 2 cols. Hudson40 Excel VBA 5 February 9th, 2005 03:27 PM
Looking for Datagrid Cols&Columns reyboy Pro VB.NET 2002/2003 1 May 25th, 2004 08:12 AM





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