我需要知道如何獲得所有的#2的clientID,所以我可以得到他們分配給的程序...到目前爲止,我的代碼只獲得#2的第一個clientID在它...從sqldatabase表獲得公共ID號#
int progs;
string Command = @"select * from clientprogram where clientProgClientID = @clientID;";
using (MySqlConnection mConnection = new MySqlConnection(mycon))
{
mConnection.Open();
using (MySqlCommand cmd2 = new MySqlCommand(Command, mConnection))
{
cmd2.Parameters.Add(new MySqlParameter("@clientID", lblcID.Text));
using (MySqlDataReader reader = cmd2.ExecuteReader())
{
if (reader.Read())
{
progs = (int)reader["clientProgramID"];
cmbProgram.Items.Add(progs);
}
}
}
mConnection.Close();
}
應該'if(reader.Read())'是一個循環嗎? – amdixon