以文本方式查看主题 - Foxtable(狐表) (http://www.foxtable.com/bbs/index.asp) -- 专家坐堂 (http://www.foxtable.com/bbs/list.asp?boardid=2) ---- [求助]成绩分布的错误 (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=101752) |
-- 作者:杰克 -- 发布时间:2017/6/6 16:03:00 -- [求助]成绩分布的错误 [求助]成绩分布的错误 班级成绩分布的代码移植到年级成绩分布表出错 错误所在事件: 详细错误信息: System.ArgumentException: 不能启用此约束,因为不是所有的值都具有相应的父值。 在 System.Data.ConstraintCollection.AddForeignKeyConstraint(ForeignKeyConstraint constraint) 在 System.Data.ConstraintCollection.Add(Constraint constraint, Boolean addUniqueWhenAddingForeign) 在 System.Data.DataRelationCollection.DataSetRelationCollection.AddCore(DataRelation relation) 在 System.Data.DataRelationCollection.Add(DataRelation relation) 在 System.Data.DataRelationCollection.Add(String name, DataColumn parentColumn, DataColumn childColumn) 在 Foxtable.Class14.smethod_2(String string_9) |
-- 作者:杰克 -- 发布时间:2017/6/6 16:08:00 -- 班级成绩分布的代码: Dim dr As DataRow = e.DataRow Dim dt As DataTable =DataTables("班级成绩表") If e.DataCol.Name = "科目" And dr.IsNull("科目") = False Then dr("最高分") = dt.Compute("Max(" & dr("科目") & ")") dr("最低分") = dt.Compute("Min(" & dr("科目") & ")") dr("平均分") = dt.Compute("Avg(" & dr("科目") & ")") dr("分布_60分以下") = dt.Compute("Count(姓名)", dr("科目") & " < 60") dr("分布_60分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 60 And " & dr("科目") & " < 70" ) dr("分布_70分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 70 And " & dr("科目") & " < 80" ) dr("分布_80分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 80 And " & dr("科目") & " < 90" ) dr("分布_90分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 90 And " & dr("科目") & " < 100" ) dr("分布_100分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 100 And " & dr("科目") & " < 110" ) dr("分布_110分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 110 And " & dr("科目") & " < 120" ) dr("分布_120分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 120 And " & dr("科目") & " < 130" ) dr("分布_130分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 130" ) Select Case dr("科目") Case "语文", "数学", "英语" dr("优秀率") = dt.Compute("Count(姓名)", dr("科目") & " >= 140") / dt.Compute("Count(姓名)") dr("及格率") = dt.Compute("Count(姓名)", dr("科目") & " >= 90") / dt.Compute("Count(姓名)") Case "物理", "化学" dr("优秀率") = dt.Compute("Count(姓名)", dr("科目") & " >= 95") / dt.Compute("Count(姓名)") dr("及格率") = dt.Compute("Count(姓名)", dr("科目") & " >= 60") / dt.Compute("Count(姓名)") End Select End If 年级成绩分布表代码: Dim dr As DataRow = e.DataRow Dim dt As DataTable =DataTables("年级成绩表") If e.DataCol.Name = "科目" And dr.IsNull("科目") = False Then dr("最高分") = dt.Compute("Max(" & dr("科目") & ")") dr("最低分") = dt.Compute("Min(" & dr("科目") & ")") dr("平均分") = dt.Compute("Avg(" & dr("科目") & ")") dr("分布_60分以下") = dt.Compute("Count(姓名)", dr("科目") & " < 60") dr("分布_60分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 60 And " & dr("科目") & " < 70" ) dr("分布_70分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 70 And " & dr("科目") & " < 80" ) dr("分布_80分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 80 And " & dr("科目") & " < 90" ) dr("分布_90分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 90 And " & dr("科目") & " < 100" ) dr("分布_100分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 100 And " & dr("科目") & " < 110" ) dr("分布_110分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 110 And " & dr("科目") & " < 120" ) dr("分布_120分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 120 And " & dr("科目") & " < 130" ) dr("分布_130分以上") = dt.Compute("Count(姓名)", dr("科目") & " >= 130" ) Select Case dr("科目") Case "语文", "数学", "英语" dr("优秀率") = dt.Compute("Count(姓名)", dr("科目") & " >= 140") / dt.Compute("Count(姓名)") dr("及格率") = dt.Compute("Count(姓名)", dr("科目") & " >= 90") / dt.Compute("Count(姓名)") Case "物理", "化学" dr("优秀率") = dt.Compute("Count(姓名)", dr("科目") & " >= 95") / dt.Compute("Count(姓名)") dr("及格率") = dt.Compute("Count(姓名)", dr("科目") & " >= 60") / dt.Compute("Count(姓名)") End Select End If [此贴子已经被作者于2017/6/6 16:14:34编辑过]
|
-- 作者:杰克 -- 发布时间:2017/6/6 16:11:00 -- 在班级成绩表的代码运行正常,但只要添加年级成绩表的代码就出错: 错误所在事件: 详细错误信息: System.ArgumentException: 不能启用此约束,因为不是所有的值都具有相应的父值。 在 System.Data.ConstraintCollection.AddForeignKeyConstraint(ForeignKeyConstraint constraint) 在 System.Data.ConstraintCollection.Add(Constraint constraint, Boolean addUniqueWhenAddingForeign) 在 System.Data.DataRelationCollection.DataSetRelationCollection.AddCore(DataRelation relation) 在 System.Data.DataRelationCollection.Add(DataRelation relation) 在 System.Data.DataRelationCollection.Add(String name, DataColumn parentColumn, DataColumn childColumn) 在 Foxtable.Class14.smethod_2(String string_9) |
-- 作者:杰克 -- 发布时间:2017/6/6 16:12:00 -- DataColChanged事件 |
-- 作者:有点色 -- 发布时间:2017/6/6 16:44:00 -- 实例发上来测试。 |