我想从 mysql 数据库中检索一些数据并填充一些文本框。问题是编译器没有进入 while (rdr.Read()) 循环。我已经检查了我的查询,但它是正确的。还有传递的变量到构造函数是正确的。这是我的代码namespace LoanApp{public partial class TablePopUp : Form{ string id; public TablePopUp(string var) { id = var; InitializeComponent(); try { ConnectDB connection = new ConnectDB(); MySqlConnection con = connection.setUpConnection(); con.Open(); string query = "SELECT * FROM debtors WHERE NIC = 'id'"; MySqlCommand cmd3 = new MySqlCommand(query, con); MySqlDataReader rdr = cmd3.ExecuteReader(); textBox1.Text = var.ToString(); while (rdr.Read()) { txtBoxSearch.Text = rdr.GetValue(1).ToString(); textBox2.Text = rdr.GetValue(5).ToString(); textBox3.Text = rdr.GetValue(4).ToString(); } rdr.Close(); con.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }}
1 回答
- 1 回答
- 0 关注
- 321 浏览
添加回答
举报
0/150
提交
取消