Reading 1 column of rows into a string

GornHorse

Well-known member
Joined
May 27, 2003
Messages
105
Location
Australia
Hi there,

My sql query is "select [col1] from table1 where [col1] like a%".

What i want to do is say...

dim liststr as string
while counter < numrows
liststr = liststr & myReader.GetString(counter)
counter = counter + 1
end while


However, myReader scrolls through each column in 1 row, i want to scroll through each row in 1 column.

How do i do this?

Your quick response will be much appreciated. If possible, please reply for vb.net

Thanks very much,
Michelle :-\
 
Perhaps Im not understanding your question clearly, but your pseudo-code looks correct to me for such a task. Unless youre asking how to do it with a single SELECT statement?
 
Your syntax is correct except for one thing instead of incrementing
the counter, dont the counter represents the column index.
(This is how data readers work).

This loop is what you need to do

dim liststr as string
while myreader.read
liststr = liststr & myReader.GetString(0)
end while

So to advance in rows of a data reader you have to use reader.read

Hope this helps....
 
Back
Top