Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / November 2007

Tip: Looking for answers? Try searching our database.

DB Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Guilherme Grillo - 12 Nov 2007 18:56 GMT
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
Alexey Smirnov - 12 Nov 2007 19:02 GMT
On Nov 12, 7:56 pm, "Guilherme Grillo" <web...@rncomtotal.com.br>
wrote:
> Friends,
>
[quoted text clipped - 47 lines]
>
> Grillo

instead of readerSELECT.Read(); use

while (readerSELECT.Read()) {
....
}
bruce barker (sqlwork.com) - 12 Nov 2007 19:09 GMT
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)

> Friends,
>
[quoted text clipped - 47 lines]
>
> Grillo

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.