First, create an SqlConnection object.
Then, create an SqlCommand object.
Run a ExecuteRead on the command.
Process the results.
The complex bit is the connection, and that will depend on your connection string, db type, etc.
sqlConnection sqlConn = new SqlConnection("Server=RIMROCK;Database=Northwind;Integrated Security=SSPI;");
SqlCommand sqlComm = new SqlCommand("SELECT userid,username FROM users ORDER BY username", sqlConn);
SqlDataReader r = sqlComm.ExecuteReader();
while ( r.Read() )
{
string username = (string)r["username"];
int userID = (int)r["userid"];
Debug.WriteLine(username + "(" + userID + ")");
}
r.Close();