<分区>
- 框架:.Net 4.5
我正在使用我的数据库中的数据填充文本框字段。但是,调试后我发现我的 Linq 查询没有返回值。
protected void btnChoose_Click(object sender, EventArgs e)
{
API_DatabaseEntities1 db = new API_DatabaseEntities1();
if (ddlCustomer.SelectedValue == "Marisol") {
tbDescription.Text = (from c in db.Customers
where c.CustomerID == 4
select c.ProductDescription).ToString();
tbFName.Text = (from c in db.Customers
where c.CustomerID == 4
select c.Fname).ToString();
tbSocial.Text = (from c in db.Customers
where c.CustomerID == 4
select c.SSN).ToString();
tbDOB.Text = (from c in db.Customers
where c.CustomerID == 4
select c.DOB).ToString();
tbFName1.Text = (from c in db.Customers
where c.CustomerID == 4
select c.Fname).ToString();
tbMName.Text = (from c in db.Customers
where c.CustomerID == 4
select c.Mname).ToString();
tbLName.Text = (from c in db.Customers
where c.CustomerID == 4
select c.Lname).ToString();
tbPrimaryPhone.Text = (from c in db.Customers
where c.CustomerID == 4
select c.PrimaryPhone).ToString();
tbSecondaryPhone.Text = (from c in db.Customers
where c.CustomerID == 4
select c.SecondaryPhone).ToString();
tbAdd1.Text = (from c in db.Customers
where c.CustomerID == 4
select c.Address).ToString();
tbCity.Text = (from c in db.Customers
where c.CustomerID == 4
select c.City).ToString();
tbZip.Text = (from c in db.Customers
where c.CustomerID == 4
select c.Zip).ToString();
tbEmail.Text = (from c in db.Customers
where c.CustomerID == 4
select c.Email).ToString();
tbMonLease.Text = (from c in db.Customers
where c.CustomerID == 4
select c.MortLeaseAmt).ToString();
tbEmployer.Text = (from c in db.Customers
where c.CustomerID == 4
select c.Employer).ToString();
tbPosition.Text = (from c in db.Customers
where c.CustomerID == 4
select c.Position).ToString();
tbHireDate.Text = (from c in db.Customers
where c.CustomerID == 4
select c.Position).ToString();
tbWorkPhone.Text = (from c in db.Customers
where c.CustomerID == 4
select c.WorkPhone).ToString();
tbGross.Text = (from c in db.Customers
where c.CustomerID == 4
select c.GrossIncome).ToString();
}
Debug.WriteLine(tbGross.Text);
}
此时我不确定我的数据库连接或我的 Linq 查询是否存在问题。感谢您提供的任何帮助。