按钮单击弹出一个新窗口

时间:2013-04-23 19:04:04

标签: c# asp.net ms-access-2007

我想知道,在按钮单击时,应显示一个弹出窗口,从数据库中收集用户类型。在该窗口中,我们可以选择一个usertype,它将填充按钮附近的文本框。我正在使用MS Access数据库和user_master表,我从中获取了usertype。

1 个答案:

答案 0 :(得分:0)

你正在寻找这样的东西:

假设您有一个文本框(choiceTxtBox),用户输入选择表单数据库的选项。

thatButton.Click += (the, game) => 
{
   db = new OleDbConnection();
   db.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + fileName;
   db.Open();

   string sql = "SELECT * FROM Table WHERE SomeField = @UserChoice";

   cmd = new OleDbCommand(sql, db);
   cmd.Parameters.AddWithValue("@UserChoice", choiceTxtBox.Text);
   rdr = cmd.ExecuteReader();

   while (rdr.Read())
   resultTxtBox.Text += ((string)rdr["GroupName"]);
};
相关问题