以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  表空时加载出错,不知如何解决?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=59040)

--  作者:audience68
--  发布时间:2014/10/28 19:17:00
--  表空时加载出错,不知如何解决?
由来请教了

今天初始化了数据库,在数据库为空时,启动程序,发现出错,出错信息如下

.NET Framework 版本:2.0.50727.5485

Foxtable 版本:2014.10.16.1

错误所在事件:窗口,监造周报窗口,AfterLoad

详细错误信息:

未将对象引用设置到对象的实例。


参照前面甜版和高手的指导,我依葫芦画瓢在AfterLoad中加了两个IF语句,整个AfterLoad代码如下:

但是修改后的代码在运行时发现大量占用内存,要等很长时间才能进入系统,但是没有报错。试着在表中维护数据,发现凡是在加载时表不为空,启动速度正常,但一旦为空,速度就非常慢。请高手看看我的代码是不是有缺陷?谢谢了!

If User.Group = "监理" Then

    DataTables("监造周报").LoadFilter = "监理人员 = \'" & User.Name & "\'"

ElseIf User.Group = "主管" Then

    DataTables("监造周报").LoadFilter = "项目经理 = \'" & User.Name & "\'"

Else

    DataTables("监造周报").LoadFilter = ""

End If

DataTables("监造周报").Load()

 

If Forms("监造周报窗口").Opened Then

    \'If Tables("监造周报").Current("审核") IsNot Nothing  Then

    If Tables("监造周报").Current IsNot Nothing Then

        Dim fm1 As WinForm.FileManager = Forms("监造周报窗口").Controls("FileManager1")

        Dim fm2 As WinForm.FileManager = Forms("监造周报窗口").Controls("FileManager2")

        Dim fm3 As WinForm.FileManager = Forms("监造周报窗口").Controls("FileManager3")

        Dim fm As WinForm.PictureViewer = Forms("监造周报窗口").Controls("PictureViewer1")

        If Tables("监造周报").Current.IsNull("审核") = False  Then \'如果周报已经审批

            fm1.AddCommand.Visible = False

            fm2.AddCommand.Visible = False

            fm3.AddCommand.Visible = False

            fm.AddCommand.Visible = False

            fm1.DeleteCommand.Visible = False

            fm2.DeleteCommand.Visible = False

            fm3.DeleteCommand.Visible = False

            fm.DeleteCommand.Visible = False

            fm1.ClearCommand.Visible = False

            fm2.ClearCommand.Visible = False

            fm3.ClearCommand.Visible = False

            fm.ClearCommand.Visible = False

            fm.ManagerCommand.Visible = False

            fm1.ManagerCommand.Visible = False

            fm2.ManagerCommand.Visible = False

            fm3.ManagerCommand.Visible = False

        Else

            fm1.AddCommand.Visible = True

            fm2.AddCommand.Visible = True

            fm3.AddCommand.Visible = True

            fm.AddCommand.Visible = True

            fm1.DeleteCommand.Visible = True

            fm2.DeleteCommand.Visible = True

            fm3.DeleteCommand.Visible = True

            fm.DeleteCommand.Visible = True

            fm.ManagerCommand.Visible = False

            fm1.ManagerCommand.Visible = False

            fm2.ManagerCommand.Visible = False

            fm3.ManagerCommand.Visible = False

        End If

    End If

End If





--  作者:有点甜
--  发布时间:2014/10/28 19:23:00
--  
 这段代码没有问题,出错例子发上来。
--  作者:audience68
--  发布时间:2014/10/29 13:30:00
--  
谢谢甜版,问题已经查到,是上次你指导的关于未维护监造日志预警语句对空表没有设置判断条件引起的,现在加了IF语句后解决。