DB Problem

G

Guilherme Grillo

Friends,

I have a table in the DataBase that have a column with repeated values...

Example

| ID | Values | RepValues |
| 1 | 5 | 1 |
| 2 | 3 | 2 |
| 3 | 7 | 2 |
| 4 | 2 | 2 |
| 5 | 9 | 3 |
| 6 | 1 | 3 |

I do a SELECT like this:
commSELECT = new SqlCommand("SELECT Values FROM contResults WHERE RepValues
= 2 ORDER BY id", conn);



THEN



try

{

conn.Open();

readerSELECT = commSELECT.ExecuteReader(CommandBehavior.CloseConnection);

readerSELECT.Read();

labelResultados.Text += "<i>- " + readerSELECT["contResults"] + "
things</i><br />";


readerSELECT.Close();



It results in:

- 3 things

And what I want is:

- 3 things
- 7 things
- 2 things



What I have to do?



Thanks
Sorry my english

Grillo
 
G

Guest

Friends,

I have a table in the DataBase that have a column with repeated values...

Example

| ID | Values | RepValues |
| 1 | 5 | 1 |
| 2 | 3 | 2 |
| 3 | 7 | 2 |
| 4 | 2 | 2 |
| 5 | 9 | 3 |
| 6 | 1 | 3 |

I do a SELECT like this:
commSELECT = new SqlCommand("SELECT Values FROM contResults WHERE RepValues
= 2 ORDER BY id", conn);

THEN

try

{

conn.Open();

readerSELECT = commSELECT.ExecuteReader(CommandBehavior.CloseConnection);

readerSELECT.Read();

labelResultados.Text += "<i>- " + readerSELECT["contResults"] + "
things</i><br />";

readerSELECT.Close();

It results in:

- 3 things

And what I want is:

- 3 things
- 7 things
- 2 things

What I have to do?

Thanks
Sorry my english

Grillo

instead of readerSELECT.Read(); use

while (readerSELECT.Read()) {
.....
}
 
G

Guest

you need to read more than 1 row. try this new fangled feature called a while
loop:

while (readerSELECT.Read())
{
labelResultados.Text += "<i>- "
+ readerSELECT["contResults"]
+ " things</i><br />";
}


-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top