好的,我有两张桌子:
内容 - >在combobox中显示,名为cntpaginaBX。
促销 - >在组合框中显示名为prmopaginaBX。
当我从rtb中显示的内容中选择一个项目时:我得到了以下代码,但它不起作用。
private void cntpaginaBX_SelectedIndexChanged(object sender, EventArgs e)
{
if (cntpaginaBX.SelectedItem == "Welkom")
{
MySqlConnection sqlConn = new MySqlConnection("Database=joshua; Data Source=localhost; User Id='root'; Password=''");
string content = "SELECT * FROM content WHERE title=Welkom";
MySqlCommand myCommando = new MySqlCommand(content, sqlConn);
MySqlDataReader sqlReader;
object welkom;
try
{
sqlConn.Open();
sqlReader = myCommando.ExecuteReader();
while (sqlReader.Read())
{
welkom = sqlReader.GetValue(0).ToString();
showText.Text = welkom.ToString();
}
sqlReader.Close();
}
catch (Exception x)
{
MessageBox.Show(x.Message, "Fout", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
sqlConn.Close();
}
}
}