因表格均支持增减列,在多人网络协同条件下,张三的外部数据表datatable(“表A”)增加了一列,李四的datatable(“表A”)在未能重新刷新表结构的时候,用load加载数据就会报错,用try也拦截不住,老师给想想办法,多谢!
'LockBaseMainForm
Dim 表名 As String = Args(0)
Dim 数据源 As String=args(1)
Dim 显示进度窗口 As Boolean = Args(2)
Dim 是否强制创建 As Boolean= Args(3)
Dim x1 As Integer
Dim y1 As Integer
Dim x2 As Integer
Dim y2 As Integer
If Tables.contains("主窗体_table1") Then
Dim t As Table=Tables("主窗体_table1")
x1=t.Toprow
y1=t.leftcol
x2=t.bottomrow
y2=t.rightcol
End If
If 显示进度窗口=True Then
Functions.Execute("失效菜单")
Functions.Execute("显示进度条","正在加载【" & 表名 & "】数据,请稍候......",100,0,100,False )
End If
If DataTables.Contains(表名)=False Or 是否强制创建=True Then
Dim q As new OuterTableBuilder
q.TableName = 表名
q.TableCaption = 表名
q.ConnectionName = 数据源
q.SelectString = "Sele ct * Fr om [" & 表名 & "] wh ere 1=0"
If Tables.contains("主窗体_table1") AndAlso Tables("主窗体_table1").DataTable.name=表名 Then
Forms("主窗体").StopRedraw
Forms("主窗体").Controls("上下面板").Visible=False
Tables("主窗体_table1").DataSource=DataTables("主窗口表")
try
q.Build
Catch ex As Exception
End try
Forms("主窗体").ResumeRedraw
Else
try
q.Build
Catch ex As Exception
End try
End If
End If
If DataTables.Contains(表名)=True Then
If DataTables(表名).DataCols.Contains("sys_审计项目编号")=True Then
DataTables(表名).dataCols( "sys_审计项目编号").DefaultValue="""" & 全局变量审计项目编号 & """"
DataTables(表名).LoadFilter="sys_审计项目编号 = '" & 全局变量审计项目编号 & "'"
Try
DataTables(表名).Load
Catch ex As Exception
全局变量更新结构表集合.add(表名)
End Try
Else
DataTables(表名).LoadFilter=""
Try
DataTables(表名).Load
Catch ex As Exception
全局变量更新结构表集合.add(表名)
End Try
End If
End If
If Tables.contains("主窗体_table1") Then
Dim t As Table=Tables("主窗体_table1")
If x1<=t.Rows.count-1 AndAlso y1<=t.Cols.count-1 AndAlso x2<=t.Rows.count-1 AndAlso y2<=t.Cols.count-1 Then
t.Select(x1,y1,x2,y2)
End If
End If
Functions.Execute("恢复窗体控件","主窗体")
Functions.Execute("恢复菜单")
If Forms("进度条窗口").Opened Then
Forms("进度条窗口").close
End If