为什么我得到ForeignKeyConstraint需要子键值错误? [英] Why am I getting ForeignKeyConstraint requires child key value error?

查看:69
本文介绍了为什么我得到ForeignKeyConstraint需要子键值错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


这是错误信息;

------------------- ---------

异常消息:


ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType需要孩子

键值(5)存在于父表中。

----------------------------

当我尝试使用DataSet1.Tables(表格)将记录插入表格时,我遇到此错误.Rows.Add(row)


相关数据结构如下表''tbl040Cmpt''

包含一个存储查询表值的字段

''lkp302SensorType''。

这是数据集中存在的关系;

\\

Me.Relations.Add (Lkp_tbl040Cmpt_lkp302SensorType,

Me.Tables(" lkp302SensorType")。列(" pkSensorTyp eId"),

Me.Tables(" tbl040Cmpt") 。列( " cmSmallint06"))

//

这是''lkp302SensorType''查找表;

\\

CREATE TABLE [lkp302SensorType](

[pkSensorTypeId] [smallint] IDENTITY(1,1)NOT NULL,

[SensorType] [varchar](50 )COLLATE SQL_Latin1_General_CP1_CI_AS NOT

NULL,

[Ord] [tinyint] NOT NULL CONSTRAINT [DF_lkp302SensorType_Ord] DEFAULT

(0),
[隐藏] [位] NOT NULL CONSTRAINT [DF_lkp302SensorType_Hide]默认

(0),

CONSTRAINT [PK_lkp302SensorType] PRIMARY KEY CLUSTERED



[pkSensorTypeId]

)WITH FILLFACTOR = 90 ON [主要]

)ON [PRIMARY]

GO

//

这是表''tbl040Cmpt''

\\

CREATE TABLE [tbl040Cmpt](

[pkComponentId] [char](36)COLLATE SQL_Latin1_General_CP1_CI_AS NOT

NULL CONSTRAINT [DF_tbl040Cmpt_pkComponentId] DEFAULT (newid()),

[fkDevice] [char](36)COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,

[fkComponentType] [int] NOT NULL,

[ComponentDescription] [varchar](100)COLLATE

SQL_Latin1_General_CP1_CI_AS NOT NULL,

[QuanSharingConfiguration] [tinyint] NOT NULL,

[QuanConfigured] [tinyint] NOT NULL CONSTRAINT

[DF_tbl040Cmpt_QuanConfigured] DEFAULT(0),

[QuanActuations] [tinyint] NOT NULL约束

[DF_tbl040Cmpt_QuanActuations] DEFAULT(1),

[cmVarchar01] [varchar](50)COLLATE SQL_Latin1_General_CP1_CI_AS NULL



[cmVarchar02] [varchar ](50)COLLATE SQL_Latin1_General_CP1_CI_AS NULL



[cmVarchar03] [varchar](50)COLLATE SQL_Latin1_General_CP1_CI_AS NULL



[cmVarchar04] [varchar](50)COLLATE SQL_Latin1_General_CP1_CI_AS NULL



[cmVarchar05] [varchar](50)COLLATE SQL_Latin1_General_CP1_CI_AS NULL



[cmVarchar06] [varchar](50)COLLATE SQL_Latin1_General_CP1_CI_AS NULL



[cmNumeric01] [数字](5) ,3)NULL,

[cmNumeric02] [数字](5,3)NULL,

[cmNumeric03] [数字](5,3)NULL,

[cmNumeric04] [数字](5,3)NULL,

[cmNumeric05] [数字](5,3)NULL,

[cmNumeric06] [数字](5,3)NULL,

[cmNumeric07] [数字](5,3)NULL,

[cmBit01] [bit] NULL,

[cmBit02] [bit] NULL,

[cmBit03] [bit] NULL,

[cmBit04] [bit] NULL,

[cmBit05] [bit] NULL,

[cmBit06] [bit] NULL,

[cmBit07] [bit] NULL,

[cmBit08] [bit] NULL,

[cmBit09] [bit] NULL,

[cmBit10] [bit] NULL,

[ cmBit11] [bit] NULL,

[cmSmallint01] [smallint] NULL,

[cmSmallint02] [smallint] NULL,

[cmSmallint03] [smallint] NULL,

[cmSmallint04] [smallint] NULL,

[cmSmallint05] [smallint] NULL,

[cmSmallint06] [smallint] NULL,

[cmSmallint07] [smallint] NULL,

[cmSmallint08 ] [smallint] NULL,

[cmTinyint01] [tinyint] NULL,

[SooOrder] [数字](5,3)NULL,

[SooPrecedent] [数字](5,3)NULL,

[SooDelay] [数字](5,3)NULL,

[SooNote] [varchar]( 255)COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[cmUserNote] [varchar](255)COLLATE SQL_Latin1_General_CP1_CI_AS NOT

NULL,

[cmCreatedOn] [smalldatetime] NOT NULL,

[cmCreatedBy] [varchar](25)COLLATE SQL_Latin1_General_CP1_CI_AS NOT

NULL,

[cmEditedOn] [smalldatetime] NOT NULL,

[cmEditedBy] [varchar](25)COLLATE SQL_Latin1_General_CP1_CI_AS NOT

NULL,

[cmrowversion] [timestamp] NOT NULL,

CONSTRAINT [PK_tbl040Cmpt] PRIMARY KEY CLUSTERED



[pkComponentId]

)WITH FILLF ACTOR = 90 ON [PRIMARY],

CONSTRAINT [FK_tbl040Cmpt_lkp202ComponentType] FOREIGN KEY



[fkComponentType]

)REFERENCES [lkp202ComponentType](

[pkComponentTypeId]

),

CONSTRAINT [FK_tbl040Cmpt_tbl030Devi]外键



[fkDevice]

)参考文献[tbl030Devi](

[pkDeviceId]

)ON DELETE CASCADE NOT FOR复制

)ON [PRIMARY]

GO

//


这里是选中的代码导致错误''

\\

Private Sub InsertCylnSensor(ByVal s As String)

''创建数据行(集合)字段)

Dim row As DataRow = _dataSet1.Tables(_currentTable).NewRow

''MessageBox.Show(" Insert for called for:" &安培; s)


尝试

''自动输入数据

row(" pkComponentId")= Guid.NewGuid.ToString

''row(" fkDevice")= _pkDeviceIdForFkAndParameter

row(" fkDevice")= f030Devi._pkDeviceIdForFkAndParameter

row(" fkComponentType" ;)= 7''运动传感器

''ClipDriver -

Clip Driver_1 Sensor_1 _ A(??)

row(" ComponentDescription" ;)= _

Me.txtComponentDescription.Text.ToString& _

" - &安培; _componentTypeNameForTitleAndCmptDescrip& " _" &安培; s $

行(" QuanSharingConfiguration")= 1

行(" QuanConfigured")=" 0" ''这将填充

用户输入数据后的OnSave

''TODO - f041Cyln - InsertCylnSensor - QuanActuations -

''传播这个对于传感器〜这是非常必要的

行(QuanActuations)= _quanOfComponentActuations

''将此传播到传感器上


''TODO - f041Cyln - InsertCylnSensor - row(" cmVarchar04")=

" On"

row(" cmVarchar04")=" On" ;

行(" cmVarchar06")= _pkCmptIdOfParentForSensorAndParameter


''给所有其他头寸一个FALSE值,只有正确的

位置为真值

''允许正确过滤

行(" cmBit01")= False''B

行(&b) ; cmBit02")= False''D

row(" cmBit04")= False''C

row(" cmBit05")= False''A


选择案例s

案例B

行(" cmBit01")= True''B

案例" ; D"

row(" cmBit02")= True''D

案例" C"

行(" cmBit04" )=真''C

案例'A"

行(" cmBit05")= True''A

结束选择


行(" cmBit06")= True''PNP NON

行(" cmBit07")= True''是运动传感器


row(" cmSmallint01")= 1

''Me.cboSensorVoltage.NSelectedValue~(1 = 24伏)

''cmSmallint02

''cmSmallint03

''cmSmallint04

''cmSmallint05

row(" cmSmallint06")= 5 ''Me.cboSensorType.NSelectedValue

~(5 =霍尔效应)

''cmSmallint07

row(" cmSmallint08")= 2

''Me.cboSensorConnection.NSelecte dValue~(2 = Micro)

row(" cmUserNote")=""

row(" cmCreatedOn")= Now.ToString

row(" cmCreatedBy")= SystemInformation.UserName.ToString

row(" cmEditedOn")= Now.ToString

row( " cmEditedBy")= SystemInformation.UserName.ToString


''以下数据由用户输入 - 稍后

''行(" cmVarchar01" ;)= ucase(Me.txtSensorIOAddress.Text)


''以下数据由用户确认 - 稍后

''行(" cmBit06" ;)= True''PNP NON


Catch an As ArgumentNullException

''空引用时引发的异常

(在Visual Basic中没有任何内容)传递给一个方法,该方法不接受

它作为有效参数。

抛出新的DBAccessException(你正在传递一个没什么作为

a参数来需要实际值的方法。,ane)

Catch ce As ConstraintException

''表示尝试
$时抛出的异常b $ b违反约束的行为。

抛出新的DBAccessException(你试图采取行动

违反约束条件。,ce)

Catch e As Exception

''表示在应用程序执行期间发生的错误。

抛出新的DBAccessException(一个意外的异常有

ocurred。",e)

结束尝试

尝试

_dataSet1.Tables(_currentTable).Rows.Add(row)' '<<< This

行导致错误

Catch diee As Data.InvalidExpressionException

''表示抛出的异常当试图

添加一个DataColumn

抛出新的DBAccessException(你想要添加的数据列是
包含错误。 ,迪耶)
Catch dsee As SyntaxErrorException

''表示当DataColumn的

Expression属性包含语法错误时引发的异常。

抛出新的DBAccessException("你正在尝试添加的数据列
包含语法错误。),dsee)

捕获e作为例外

MessageBox.Show(" Exception Message:" &安培; vbCrLf& e.Message)

MessageBox.Show(" Exception Source:"& vbCrLf& e.Source)

MessageBox.Show(" Exception StackTrace:" ;& vbCrLf&

e.StackTrace)

''表示在应用程序执行期间发生的错误。

''抛出新的DBAccessException( 一个意想不到的例外

已经出现。,e)

结束尝试


结束子

//

错误说明

ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType要求子表

键值(5)存在于父表中。


5是这里显示的

行中字段cmSmallint06的值;

\\

row(" cmSmallint06" )= 5''Me.cboSensorType.NSelectedValue~(5 =

霍尔效应)

//


我不喜欢当我通过

所需的值时,我不明白为什么我会收到此错误。有人可以解释一下可能会有什么问题吗?


(5 =霍尔效应)


请帮助我。

谢谢,

dbuchanan

解决方案

Dbuchan,


AFAIK,它是否表示有一个或多个子行,在父数据表中不存在

相关键,而在
$ b中$ b孩子,所以它不能设置与父母的关系。


就是这样。


Cor

Cor,


我很难理解你的帖子。


" do is says" >它说什么


做什么*说什么?我的代码?,错误?


一个或多个子行 (?)你是说你认为错误是关于一个或多个子行的错误。 - 没有错误没有说什么

关于一行或多行,只是关于子键值。

该值是(5)因为这是我分配给它的。查看代码。


相关密钥不存在 -

关系中没有任何遗漏。关系*是*正确组成的。如果它不是
代码将无法编译。我会得到那些波浪线。


我很难理解你的帖子。 〜表格和字段的查找表之间有一个

的关系

''cmSmallint06''。它是正确的组成。请再次查看我的帖子



谢谢,

dbuchanan


> 相关密钥不存在 -

关系中没有任何遗漏。关系*是*正确组成的。如果它不是代码将无法编译。我会得到波浪线。


这种关系确实设置正确 - 至少就编译器而言是b
,但当你将关系添加到数据集时,

此时的数据集包含某些违规行,其中不满足异物
键。问题不在你的代码中,而是数据中的数据是

加载到数据集中。


- Sahil Malik [MVP]

ADO.NET 2.0书 -
http://codebetter.com/blogs/sahil.ma.../13/63199.aspx

-------- -------------------------------------------------- ------------------


" dbuchanan" <分贝********* @ hotmail.com>在消息中写道

新闻:11 ********************* @ z14g2000cwz.googlegro ups.com ... Cor,
我很难理解你的帖子。

就是说 >它是什么意思

做什么*说什么?我的代码?,错误?

一个或多个子行 (?)你是说你认为错误是关于一个或多个子行的错误。 - 没有错误没有说任何关于一行或多行的内容,只是关于子键值。
该值是(5)因为这是我分配给它的。请参阅代码。

相关密钥不存在 -
关系中没有任何遗漏。关系*是*正确组成的。如果它不是代码将无法编译。我会得到那些波浪线。

我很难理解你的帖子。 〜表和查找表之间有一个
关系字段
''cmSmallint06''。它是正确的组成。请再次查看我的帖子。

谢谢你,
dbuchanan



Hello,

Here is the error message;
----------------------------
Exception Message:

ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child
key values (5) to exist in the parent table.
----------------------------

I am encountering this error when I try to insert records into table
''tbl040Cmpt'' using the DataSet1.Tables("Table").Rows.Add(row)

The relevant data structure goes like this the table ''tbl040Cmpt''
contains a field that stores the value from lookup table
''lkp302SensorType''.
Here is the relationship that exists in the Dataset;
\\
Me.Relations.Add("Lkp_tbl040Cmpt_lkp302SensorType" ,
Me.Tables("lkp302SensorType").Columns("pkSensorTyp eId"),
Me.Tables("tbl040Cmpt").Columns("cmSmallint06"))
//
Here is the ''lkp302SensorType'' lookup table;
\\
CREATE TABLE [lkp302SensorType] (
[pkSensorTypeId] [smallint] IDENTITY (1, 1) NOT NULL ,
[SensorType] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
NULL ,
[Ord] [tinyint] NOT NULL CONSTRAINT [DF_lkp302SensorType_Ord] DEFAULT
(0),
[Hide] [bit] NOT NULL CONSTRAINT [DF_lkp302SensorType_Hide] DEFAULT
(0),
CONSTRAINT [PK_lkp302SensorType] PRIMARY KEY CLUSTERED
(
[pkSensorTypeId]
) WITH FILLFACTOR = 90 ON [PRIMARY]
) ON [PRIMARY]
GO
//
Here are table ''tbl040Cmpt''
\\
CREATE TABLE [tbl040Cmpt] (
[pkComponentId] [char] (36) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
NULL CONSTRAINT [DF_tbl040Cmpt_pkComponentId] DEFAULT (newid()),
[fkDevice] [char] (36) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[fkComponentType] [int] NOT NULL ,
[ComponentDescription] [varchar] (100) COLLATE
SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[QuanSharingConfiguration] [tinyint] NOT NULL ,
[QuanConfigured] [tinyint] NOT NULL CONSTRAINT
[DF_tbl040Cmpt_QuanConfigured] DEFAULT (0),
[QuanActuations] [tinyint] NOT NULL CONSTRAINT
[DF_tbl040Cmpt_QuanActuations] DEFAULT (1),
[cmVarchar01] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
[cmVarchar02] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
[cmVarchar03] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
[cmVarchar04] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
[cmVarchar05] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
[cmVarchar06] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
[cmNumeric01] [numeric](5, 3) NULL ,
[cmNumeric02] [numeric](5, 3) NULL ,
[cmNumeric03] [numeric](5, 3) NULL ,
[cmNumeric04] [numeric](5, 3) NULL ,
[cmNumeric05] [numeric](5, 3) NULL ,
[cmNumeric06] [numeric](5, 3) NULL ,
[cmNumeric07] [numeric](5, 3) NULL ,
[cmBit01] [bit] NULL ,
[cmBit02] [bit] NULL ,
[cmBit03] [bit] NULL ,
[cmBit04] [bit] NULL ,
[cmBit05] [bit] NULL ,
[cmBit06] [bit] NULL ,
[cmBit07] [bit] NULL ,
[cmBit08] [bit] NULL ,
[cmBit09] [bit] NULL ,
[cmBit10] [bit] NULL ,
[cmBit11] [bit] NULL ,
[cmSmallint01] [smallint] NULL ,
[cmSmallint02] [smallint] NULL ,
[cmSmallint03] [smallint] NULL ,
[cmSmallint04] [smallint] NULL ,
[cmSmallint05] [smallint] NULL ,
[cmSmallint06] [smallint] NULL ,
[cmSmallint07] [smallint] NULL ,
[cmSmallint08] [smallint] NULL ,
[cmTinyint01] [tinyint] NULL ,
[SooOrder] [numeric](5, 3) NULL ,
[SooPrecedent] [numeric](5, 3) NULL ,
[SooDelay] [numeric](5, 3) NULL ,
[SooNote] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[cmUserNote] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
NULL ,
[cmCreatedOn] [smalldatetime] NOT NULL ,
[cmCreatedBy] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
NULL ,
[cmEditedOn] [smalldatetime] NOT NULL ,
[cmEditedBy] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
NULL ,
[cmrowversion] [timestamp] NOT NULL ,
CONSTRAINT [PK_tbl040Cmpt] PRIMARY KEY CLUSTERED
(
[pkComponentId]
) WITH FILLFACTOR = 90 ON [PRIMARY] ,
CONSTRAINT [FK_tbl040Cmpt_lkp202ComponentType] FOREIGN KEY
(
[fkComponentType]
) REFERENCES [lkp202ComponentType] (
[pkComponentTypeId]
),
CONSTRAINT [FK_tbl040Cmpt_tbl030Devi] FOREIGN KEY
(
[fkDevice]
) REFERENCES [tbl030Devi] (
[pkDeviceId]
) ON DELETE CASCADE NOT FOR REPLICATION
) ON [PRIMARY]
GO
//

Here is selected code that causes the error''
\\
Private Sub InsertCylnSensor(ByVal s As String)
''Create a data row (collection of fields)
Dim row As DataRow = _dataSet1.Tables(_currentTable).NewRow
''MessageBox.Show("Insert is called for: " & s)

Try
'' Data entered automatically
row("pkComponentId") = Guid.NewGuid.ToString
''row("fkDevice") = _pkDeviceIdForFkAndParameter
row("fkDevice") = f030Devi._pkDeviceIdForFkAndParameter
row("fkComponentType") = 7 ''Motion sensor
'' ClipDriver -
Clip Driver_1 Sensor_1 _ A(??)
row("ComponentDescription") = _
Me.txtComponentDescription.Text.ToString & _
" - " & _componentTypeNameForTitleAndCmptDescrip & "_" & s

row("QuanSharingConfiguration") = 1
row("QuanConfigured") = "0" ''This will be populated
OnSave after user enters data
''TODO - f041Cyln - InsertCylnSensor - QuanActuations -
''Propagate this on to the sensors ~ is this really necessary
row("QuanActuations") = _quanOfComponentActuations
''Propagate this on to the sensors

''TODO - f041Cyln - InsertCylnSensor - row("cmVarchar04") =
"On"
row("cmVarchar04") = "On"
row("cmVarchar06") = _pkCmptIdOfParentForSensorAndParameter

''Give all other positions a FALSE value and only the proper
position a TRUE value
'' This allows proper filtering
row("cmBit01") = False ''B
row("cmBit02") = False ''D
row("cmBit04") = False ''C
row("cmBit05") = False ''A

Select Case s
Case "B"
row("cmBit01") = True ''B
Case "D"
row("cmBit02") = True ''D
Case "C"
row("cmBit04") = True ''C
Case "A"
row("cmBit05") = True ''A
End Select

row("cmBit06") = True ''PNP NON
row("cmBit07") = True ''is Motion sensor

row("cmSmallint01") = 1
''Me.cboSensorVoltage.NSelectedValue ~ (1 = 24 volt)
''cmSmallint02
''cmSmallint03
''cmSmallint04
''cmSmallint05
row("cmSmallint06") = 5 ''Me.cboSensorType.NSelectedValue
~ (5 = Hall effect)
''cmSmallint07
row("cmSmallint08") = 2
''Me.cboSensorConnection.NSelectedValue ~ (2 = Micro)

row("cmUserNote") = ""
row("cmCreatedOn") = Now.ToString
row("cmCreatedBy") = SystemInformation.UserName.ToString
row("cmEditedOn") = Now.ToString
row("cmEditedBy") = SystemInformation.UserName.ToString

'' The following data is entered by the user - later
''row("cmVarchar01") = ucase(Me.txtSensorIOAddress.Text)

'' The following data is confirmed by the user - later
''row("cmBit06") = True ''PNP NON

Catch ane As ArgumentNullException
''The exception that is thrown when a null reference
(Nothing in Visual Basic) is passed to a method that does ''not accept
it as a valid argument.
Throw New DBAccessException("You are passing a ''Nothing'' as
a parameter to a method where an actual value is required.", ane)
Catch ce As ConstraintException
''Represents the exception that is thrown when attempting an
action that violates a constraint.
Throw New DBAccessException("You have attempted an action
that violates a constraint.", ce)
Catch e As Exception
''Represents errors that occur during application execution.
Throw New DBAccessException("An unanticipated exception has
ocurred.", e)
End Try
Try
_dataSet1.Tables(_currentTable).Rows.Add(row) ''<<<This
line causes the error
Catch diee As Data.InvalidExpressionException
''Represents the exception that is thrown when attempting to
add a DataColumn
Throw New DBAccessException("The data column you are
attempting to add contains an error.", diee)
Catch dsee As SyntaxErrorException
''Represents the exception that is thrown when the
Expression property of a DataColumn contains a syntax error.
Throw New DBAccessException("The data column you are
attempting to add contains a syntax error.", dsee)
Catch e As Exception
MessageBox.Show("Exception Message: " & vbCrLf & e.Message)
MessageBox.Show("Exception Source: " & vbCrLf & e.Source)
MessageBox.Show("Exception StackTrace: " & vbCrLf &
e.StackTrace)
''Represents errors that occur during application execution.
''Throw New DBAccessException("An unanticipated exception
has ocurred.", e)
End Try

End Sub
//
The error says
ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child
key values (5) to exist in the parent table.

The "5" is the value that is given to the field cmSmallint06 in the
line shown here;
\\
row("cmSmallint06") = 5 ''Me.cboSensorType.NSelectedValue ~ (5 =
Hall effect)
//

I don''t understand why I am getting this error when I am passing the
required value. Can someone explain what might be casusing this?

(5 = Hall effect)

Please help me.

Thank you,
dbuchanan

解决方案

Dbuchan,

AFAIK, does it says that there is one or more child rows from which the
related key does not exist in your parent datatable while it does in the
child, so it cannot set the relation to the parent.

That is all.

Cor


Cor,

I am having difficulty understanding your post.

"does is says" > does it SAY

does *what* say? my code?, the error?

"one or more child rows" (?) are you saying you think the error is
about "one or more child rows" - no the error does not say anything
about one or more rows, just about child key values.
That value is (5) because that is what I assigned to it. See the code.

"related key does not exist" - no there is nothing missing in the
relationship. The relationship *is* correctly composed. If it were not
the code would not compile. I would get the squiggly lines.

It is difficult for me to understand your post. ~ There is one
relationship between the table and the lookup table for the field
''cmSmallint06''. and it is correctly composed. Please review my post
again.

Thank you,
dbuchanan


> "related key does not exist" - no there is nothing missing in the

relationship. The relationship *is* correctly composed. If it were not
the code would not compile. I would get the squiggly lines.
The relationship is indeed set correctly - atleast as far as the compiler is
concerned, but at the time you are adding the relationship to your dataset,
the dataset at that time contains certain offending rows where the foreign
key is not satisfied. The problem is not in your code, it''s in the data that
is loaded in the dataset.

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.ma.../13/63199.aspx
----------------------------------------------------------------------------

"dbuchanan" <db*********@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com... Cor,

I am having difficulty understanding your post.

"does is says" > does it SAY

does *what* say? my code?, the error?

"one or more child rows" (?) are you saying you think the error is
about "one or more child rows" - no the error does not say anything
about one or more rows, just about child key values.
That value is (5) because that is what I assigned to it. See the code.

"related key does not exist" - no there is nothing missing in the
relationship. The relationship *is* correctly composed. If it were not
the code would not compile. I would get the squiggly lines.

It is difficult for me to understand your post. ~ There is one
relationship between the table and the lookup table for the field
''cmSmallint06''. and it is correctly composed. Please review my post
again.

Thank you,
dbuchanan



这篇关于为什么我得到ForeignKeyConstraint需要子键值错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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