1
需要幫助, 我需要將標題放入名爲cntpaginaBX和prmopaginaBX的組合框中。 與一個它的作品,但是當我嘗試兩個..它失敗。 我想知道的是「MySqlCommand」。 我如何解決它,因爲它不採取內容,促銷,sqlconn togheter。MySqlCommand:如何將標題放入組合框
MySqlConnection sqlConn = new MySqlConnection("Database=joshua;
Data Source=localhost; User Id='root'; Password=''");
string content = "SELECT title FROM content";
string promo = "SELECT title FROM promo";
MySqlCommand myCommando = new MySqlCommand(content, promo, sqlConn); <-----here
MySqlDataReader sqlReader;
object cont;
object prom;
try
{
sqlConn.Open();
sqlReader = myCommando.ExecuteReader();
while (sqlReader.Read())
{
cont = sqlReader.GetValue(0).ToString();
cntpaginaBX.Items.Add(cont);
prom = sqlReader.GetValue(0).ToString();
prmopaginaBX.Items.Add(prom);
}
sqlReader.Close();
}
catch (Exception x)
{
MessageBox.Show(x.Message, "Fout", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
sqlConn.Close();
}
感謝您的幫助 – 2011-04-30 13:33:44
關注的問題是在prmopaginaBX從內容的標題都出現了 – 2011-04-30 13:52:52
好吧,我得到它,發現了一些沒有刪除的行 – 2011-04-30 13:57:22