How do I add contents of a column from an access database to different tetboxes?

Currently I am querying a column in a database by               "SELECT [First Name] FROM [Player] WHERE [Team]=2000";
When viewing the results with this command                        " MessageBox.Show(Convert.ToString(dbReader.GetValue(0)));"

everything works fine and I get different messageboxes for each name. (John, Terry, Chris, Jared, all in different messageboxes)
but how can I put these values in different textboxes? Any help would be great. Thanks
LVL 3
zstafaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chester_M_RagelCommented:
You must loop through the values and get a collection of name. From that collection, you can fill the text box.
0
zstafaAuthor Commented:
Could you be a little more specific please. All of the values I want are in dbReader.GetValue(0) according to MessageBox.Show. Thanks alot for your help.
0
Chester_M_RagelCommented:
For example, if you are using arraylist, then you can loop throguh all the elements in dbreader and add those into an arraylist. For eg.

ArrayList al = new ArrayLsit();
while(dbReader.Read())
{
al.Add(Convert.ToString(dbReader.GetValue(0)));
}

Chester
0
Mohammed NasmanSoftware DeveloperCommented:
Hello

  It's will be better to use ComboBox or ListBox for this task, because these controls best used to show more than record for the same field, if you would to use different fields, then use TextBox

      while( dbReader.Read())
      {
            listBox1.Items.Add(dbReader.GetValue(0).ToString());                        

      }

but if you still would like to use TextBox to display the values, then build them in runtime
as following:


      int i = 0;
      while( dbReader.Read())
      {
            TextBox txt = new TextBox();                        
            txt.Text =dbReader.GetValue(0).ToString();
            txt.Top = i;
            this.Controls.Add(txt);
            i = i + 20;
      }


HTH

Regards,
Mohammed
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.