0

Hi all,

I have a combo box which i wish to display all the Usernames from the table Users, but with the UsergroupID of 1. However my codes currently displays ALL Username records. How can i modify it to only fetch Usernames records with the UsergroupID of 1?

Codes as follows:

string query = "SELECT Username FROM Users";
OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, sConnectionString);
DataTable source = new DataTable();
dAdapter.Fill(source);
UsernameComboBox.DataSource = source;
UsernameComboBox.DisplayMember = "Username";

Table: Users
- ID (PK)
- Username
- UsergroupID

Any help will be greatly appreciated, cheers!

Edited by pacheco: n/a

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Ketsuekiame
0

I have solved it, thanks.

string query = "SELECT Username, UsergroupID FROM Users WHERE (UsergroupID = 1)";
            OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, sConnectionString);
            DataTable source = new DataTable();
            dAdapter.Fill(source);
            UsernameComboBox.DataSource = source;
            UsernameComboBox.DisplayMember = "Username";
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.