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编辑过]