我有問題我無法將數據加載到文本框中,查詢從窗體中的數據庫中獲取。 while循環無法執行。如何解決這個問題。或沒有任何錯誤或例外。內部命令不能執行調試器移動來捕獲和完成。如何從sql數據庫表加載數據到文本框
private void btnCheck_Click(object sender, EventArgs e)
{
try
{
// query = "SELECT Id, Emplname, CNIC, City, MobileNo, Address, Salary, DailyWage, CompanyId, Status FROM Employees where id = '" + labCompyId.Text + "'";
query = "SELECT CNIC, City, MobileNo, Address, Salary, DailyWage, Status FROM Employees WHERE (EmployId = '"+txtEmployId+"') AND (Emplname = '"+txtEmplyName+"')";
SqlCommand command1 = DBConnectivity.getCommandForQuery(query, connection);
SqlDataReader reader1 = command1.ExecuteReader();
while(reader1.Read())
{
this.txtCNIC.Text = (reader1["CNIC"].ToString());
this.txtEmplyCity.Text = (reader1["City"].ToString());
this.txtEmplyAddress.Text = (reader1["Address"].ToString());
this.txtSalary.Text = (reader1["Salary"].ToString());
this.txtDailyWage.Text = (reader1["DailyWage"].ToString());
reader1.Close();
}
}
catch (Exception ex)
{
}
}
你有什麼例外,你正在進入'catch'塊? –