错误保存到SQL ..... [英] Error Save To SQL.....

查看:70
本文介绍了错误保存到SQL .....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此代码保存我的数据



I use this code to save my data

try
            {
                var db = new FakturaMorsalInvestDBEntities();
                var kund = new KUND();

                kund.Kundr_ID = Convert.ToInt32(TextBoxKundnr.Text);
                kund.Namn = TextBoxNamn.Text;
                kund.OrgNummer = TextBoxOrgNr.Text;
                kund.MomsRegNummer = Convert.ToInt32(TextBoxMomsregnr.Text);
                kund.Foretag = RadioButtonForetag.Text;
                kund.PrivatPerson = RadioButtonPrivatperson.Text;
                kund.AvdelningCO = TextBoxavdelningCO.Text;
                kund.Postadress = TextBoxPostadress.Text;
                kund.PostnrOrt = TextBoxPostnrOrt.Text;
                kund.Land = TextBoxLand.Text;
                kund.Epost = TextBoxEpost.Text;
                kund.Webbplats = TextBoxWebbplats.Text;
                kund.Telefon = TextBoxTelefon.Text;
                kund.Betalningsvillkor = Convert.ToInt32(comboBoxbetalningsdagar.Text);
                kund.Valuta = comboBoxValuta.Text;
                kund.Moms = textBoxmoms.Text;
                kund.SkickaFakturaMedEPost = radioButtonEPost.Text;

                db.KUND.Add(kund);
                db.SaveChanges();





但我得到以下错误?

系统。 Data.Entity.Validation.DbEntityValidationResult



But i get this following error?
System.Data.Entity.Validation.DbEntityValidationResult

推荐答案

我们无法帮助您。我们无法访问任何接近我们所需信息的地方 - 但是您可以这样做。



您需要查看您的数据 - 文本框及其内容 - 和KUND定义(我们都无法访问)并开始将它们与您的数据库进行比较。那里的东西不匹配,我们甚至无法开始找出什么。因此,在声明新的KUND实例的行上放置一个断点,然后运行你的程序:

We can't help you. We don't have access to anywhere near the information we would need - but you do.

You need to look at your data - the textboxes and their content mostly - and the KUND definition (neither of which we have access to) and start comparing those with your database. Something in there does not match, and we can't even begin to find out what. So, put a breakpoint on the line declaring a new instance of KUND, and run your program:
var kund = new KUND();

当调试器遇到断点时,你可以开始查看它是什么,然后逐步进入代码以找出发生了什么。



如果你得到一个特定的案例并且它仍然没有意义,那么请再次询问,但有相关信息。祝你好运!

When the debugger hits the breakpoint, you can start looking at what is what, and stepping through into the code to find out what is happening.

If you get a specific case and it really still doesn't make sense, then please ask again, but with the relevant info. Good Luck!


这篇关于错误保存到SQL .....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆