English 中文(简体)
与《公约》有关的《公约》
原标题:Mysterious constraint violation in c# db-related code

我利用储存的胎盘从 d中获取数据(Sql 2008 r2明示)。 来源表中的2个领域可能包含国家不动产价值,因此,如果在数据库设计师的VS项目上增加数据来源,从而把不动产留给(Empty)的不动产和不动产(两个领域都在修缮)。

尽管采取了所有这些行动,但每次产生数据集时都会例外,试图以无效价值增长。 我检查了所有情况:请允许我指出,纽埃勒韦莱是真的,没有独特的钥匙。

我的法典有什么错误?

UPD "Exception message: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints."

法典:

foreach (BusStationDataSet.selectCarrierListRow row in _tblSource.Rows)
                    {
//Next line of code throws exception
                        BusStationDataSet.selectCarrierPhonesDataTable _tblPhones = _taPhones.GetData(row.carrierId, Settings.Default.DataLanguage);
                        phones = string.Empty;
                        int i = 0;

                        foreach (BusStationDataSet.selectCarrierPhonesRow phoneRow in _tblPhones.Rows)
                        {
                            i++;
                            string end = i == _tblPhones.Rows.Count ? "" : ", ";

                            phones += (phoneRow.countryCode != string.Empty ? phoneRow.countryCode : "") + (phoneRow.regionCode != string.Empty ? " (" + phoneRow.regionCode + ") " : "") + phoneRow.number +
                                end;
                        }
                        phones = phones == string.Empty ? MultilangInterface.Instance.GetMessageString(MultilangInterface.Messages.NullValue) : phones;

                        _dsDestination.Tables["Carrier"].Rows.Add(new object[]{
                            null,
                            row.carrierId,
                            row.title,
                            row.carrierType,
                            row.country,
                            row.city,
                            row.country + ", " + row.region + ", " + row.city + ", " + row.street + ", " + row.building + (string.IsNullOrEmpty(row.addressLine)?"":", " + row.addressLine),
                            row.lastName +" "+ row.firstName +" "+ row.middleName,
                            phones
                        });
                    }
最佳回答

最后,我发现这个问题。 项目数据集中有两个生成的表格,其名称几乎相同:.selectCarriersPhonesDataTable.selectCarrierPhonesDataable。 第二类是例外,因为对于两个可取消的领域而言,<代码>NullValue财产被设定为(三个除外)。 在我摆脱这种模糊不清之后,一切都证明是无益的。 当然,我应该有足够的睡觉:

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签