使用数据库中的Kundnr

编程入门 行业动态 更新时间:2024-10-15 16:25:30
本文介绍了使用数据库中的Kundnr_ID填充Combobox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

从数据库中获取数据并在组合框中显示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

本文发布于:2023-11-02 04:02:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551316.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库中   Kundnr

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!