从数据库中获取数据并在组合框中显示Kundnr_ID。我已经将3个值保存到数据库中我得到数量3 但是Kundnr_ID是1,2,10但是在组合框中它显示0,0,0为什么? 我的kund类看起来像这样
Get data from database and display the Kundnr_ID in a combobox. i have saved 3 values to the datbase i get count 3 But the Kundnr_ID are 1,2,10 but in the combobox it displays 0,0,0 why? my kund class looks like this
public class kunder { public int KundnrId { get; set; } }此代码用于填充ComboBox
And this code is use to fill the ComboBox
private void FillCombo() { var db = new FakturaDB(); var s = new FakturaDBEntities(); var kund = (from p in s.FakturaDB select new kunder { KundnrId = db.Kundnr_ID }).ToList(); List<int> myProgSkillList = new List<int>(); foreach (var vProgSkill in kund) { myProgSkillList.Add(vProgSkill.KundnrId); } comboBoxDisplayNameDB.DataSource = myProgSkillList;推荐答案
我们可以'告诉你 - 你必须自己寻找。 假设 We can't tell - you will have to look for yourself. Assuming that var s = new FakturaDBEntities();
从数据库中读取数据,然后您需要查看它,并准确计算它正在做什么,以及它返回的值是否包括零或ID中的值物业。 如果它是零,那么你需要查看代码并找出原因。 或者,如果可能只是那个你没有正确使用任何东西:
Reads your data from the DB, then you you need to look at it, and work out exactly what it is doing, and if the values it returns include zeros, or values in your ID property. If it's zeros, then you need to look at that code and work out why. Alternatively, if could just be that you aren't using anything correctly:
var kund = (from p in s.FakturaDB select new kunder { KundnrId = db.Kundnr_ID }).ToList();也许,你想要使用每次循环更改的p,而不是db,而不是db?
Perhaps, you want to use the "p" that changes each time round the loop, instead of "db" which doesn't?
var kund = (from p in s.FakturaDB select new kunder { KundnrId = p.Kundnr_ID }).ToList();
更多推荐
使用数据库中的Kundnr
发布评论