Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2004-11-21
4
Medium Priority
?
210 Views
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
0
Comment
Question by:zstafa
  • 2
4 Comments
 
LVL 6

Expert Comment

by:Chester_M_Ragel
ID: 12641273
You must loop through the values and get a collection of name. From that collection, you can fill the text box.
0
 
LVL 3

Author Comment

by:zstafa
ID: 12641445
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
 
LVL 6

Expert Comment

by:Chester_M_Ragel
ID: 12641512
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
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 1000 total points
ID: 12642009
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month15 days, 9 hours left to enroll

580 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