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

Posted on 2004-11-21
Last Modified: 2010-04-15
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
Question by:zstafa
    LVL 6

    Expert Comment

    You must loop through the values and get a collection of name. From that collection, you can fill the text box.
    LVL 3

    Author Comment

    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.
    LVL 6

    Expert Comment

    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();

    LVL 22

    Accepted Solution


      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())


    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;
                i = i + 20;



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Hire Top Freelancers to Complete C# Projects

    Source the talented Expert Exchange community
    for top quality work on your C# projects.

    Hire the best. Collaborate easily. Get quality work.

    In one of my recent projects, I was working with IP cameras, I need to take some pictures from the camera and do some processing on it. The first step, was to retrieve the image from camera into Image object. So that it can be displayed or …
    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now