以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 动态生成关联表问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=82951) |
-- 作者:supwork -- 发布时间:2016/3/28 19:41:00 -- 动态生成关联表问题 Dim strTableName As String = "订单_主表" Dim drs As List(Of DataRow) drs = DataTables("表关联").Select("[主表] = \'" & strTableName & "\'") For Each dr As DataRow In drs Dim Col1a As String() = dr("主表字段").split(",") ‘处理多关联列 Dim Col2a As String() = dr("明细表字段").split(",") ‘处理多关联列 Dim DataCols1() As DataCol ‘处理多关联列 Dim DataCols2() As DataCol ‘处理多关联列 Dim glname As String = dr("关联名称") Dim mxtablename As String = dr("明细表") For i As Integer = 0 To Col1a.Length - 1 DataCols1(i) = DataTables(strTableName).DataCols(Col1a(i)) ‘处理多关联列 DataCols2(i) = DataTables(mxtablename).DataCols(Col2a(i)) ‘处理多关联列 Next Relations.Add(glname, DataCols1, DataCols2) Next 请教红色部份代码怎么也能不过 提示: --------------------------- 版本:2015.12.22.1 --------------------------- 代码执行出错,错误信息: System.NullReferenceException: 未将对象引用设置到对象的实例。 在 UserCode.Test() --------------------------- 确定 --------------------------- 代码改成 Dim strTableName As String = "订单_主表" Dim drs As List(Of DataRow) drs = DataTables("表关联").Select("[主表] = \'" & strTableName & "\'") For Each dr As DataRow In drs Dim Col1a As String() = dr("主表字段").split(",") Dim Col2a As String() = dr("明细表字段").split(",") Dim js As Integer = Col1a.Length Dim DataCols1(js) As DataCol Dim DataCols2(js) As DataCol Dim glname As String = dr("关联名称") Dim mxtablename As String = dr("明细表") \'Functions.Execute("HuaDataTableJg",mxtablename) msgbox(1) For i As Integer = 0 To js - 1 DataCols1(i) = DataTables(strTableName).DataCols(Col1a(i)) DataCols2(i) = DataTables(mxtablename).DataCols(Col2a(i)) Next msgbox(2) Relations.Add(glname,DataCols1,DataCols2,True,1) Next \' 则这一句 增加关联表通不过
[此贴子已经被作者于2016/3/28 19:51:45编辑过]
|
-- 作者:大红袍 -- 发布时间:2016/3/28 19:51:00 -- Dim DataCols1(Col1a.length-1) As DataCol ‘处理多关联列
Dim DataCols2(Col2a.length-1) As DataCol ‘处理多关联列
[此贴子已经被作者于2016/3/28 19:52:26编辑过]
|
-- 作者:supwork -- 发布时间:2016/3/28 19:53:00 -- 报错 --------------------------- 版本:2015.12.22.1 --------------------------- 代码执行出错,错误信息: System.NullReferenceException: 未将对象引用设置到对象的实例。 在 Foxtable.DataRelationCollection.Add(String RelationName, DataCol[] ParentCols, DataCol[] ChildCols, Boolean Visible, RelationPathEnum RelationTable) 在 UserCode.Test() --------------------------- 确定 --------------------------- |
-- 作者:supwork -- 发布时间:2016/3/28 19:58:00 -- 好了 谢谢 |
-- 作者:大红袍 -- 发布时间:2016/3/28 19:58:00 -- Dim DataCols1(js-1) As DataCol
Dim DataCols2(js-1) As DataCol
|