Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > A little help with getrows()

Reply
Thread Tools

A little help with getrows()

 
 
j1c
Guest
Posts: n/a
 
      11-16-2004
I'm using getrows to return the values from two columns in a MSSQL sql
database. Looping through them like so:
dim irowloop, icolloop, i
for irowloop = 0 to ubound(instances, 2)
for icolloop = 0 to ubound(instances, 1)
response.write("<option value=""VAL"">") 'get 2nd col val
response.write(i(icolloop, irowloop))
response.write("</option>")
next
next

How can I get the value of the second column into the VALUE=""
attribute in the drop down?

 
Reply With Quote
 
 
 
 
Chris Hohmann
Guest
Posts: n/a
 
      11-16-2004
"j1c" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> I'm using getrows to return the values from two columns in a MSSQL sql
> database. Looping through them like so:
> dim irowloop, icolloop, i
> for irowloop = 0 to ubound(instances, 2)
> for icolloop = 0 to ubound(instances, 1)
> response.write("<option value=""VAL"">") 'get 2nd col val
> response.write(i(icolloop, irowloop))
> response.write("</option>")
> next
> next
>
> How can I get the value of the second column into the VALUE=""
> attribute in the drop down?
>


Response.Write "<option value='" & Server.HTMLEncode(instances(1,irowloop))
& "'>"


 
Reply With Quote
 
 
 
 
j1c
Guest
Posts: n/a
 
      11-16-2004
Sorry, but I am not sure I completely understand how that works.

Your example gives just what I was looking for, however the content
between the <option> tags now show both column values as items in the
drop down.

 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      11-16-2004
j1c wrote:
> Sorry, but I am not sure I completely understand how that works.
>
> Your example gives just what I was looking for, however the content
> between the <option> tags now show both column values as items in the
> drop down.


The array created from GetRows has two dimensions. The first dimension
corresponds to the column number, the second to the row number. To reference
the first column in the first row, you would say
getrowsarray(0,0)
(remember, the indexes are zero-based).
To reference the second column in the first row, you would do say
getrowsarray(1,0)
3rd column, second row:
getrowsarray(2,1)

clear?

I don't know why you're using a nested loop. Assuming you want the data in
the second column to be the value, and the data in the first column to be
the text, this should do what you want:

for irowloop = 0 to ubound(instances, 2)
Response.Write "<option value='" & _
Server.HTMLEncode(instances(1,irowloop)) & "'>"
response.write Server.HTMLEncode(instances(0, irowloop))
response.write("</option>")
next

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
j1c
Guest
Posts: n/a
 
      11-16-2004
Great - thank you Bob!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
1 little 2 little 3 little Kennedys dale Digital Photography 0 03-23-2008 01:03 PM
having a little problem with some code for a little game I am creating. ThaDoctor C++ 3 09-28-2007 03:28 PM
little red X in little white box Puzzled Computer Support 8 12-13-2004 09:11 AM
Need a little access list help Bob [BVP] Cisco 9 06-11-2004 03:47 PM
A little regex help? Ivan Marsh Perl 1 07-04-2003 06:00 PM



Advertisments