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!

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";