以文本方式查看主题

-  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=83180)

--  作者:zhangyj
--  发布时间:2016/4/2 12:52:00
--  [求助]打开项目提示“未将对象引用设置到对象的实例”
我创建了一个窗口,窗口中只有有个treeview控件,在窗口afterload事件中加载treeview的数据,窗口属性为停靠。
关闭项目重新打开项目就会提示"未将对象引用设置到对象的实例" , 为什么在项目打开的时候就检查afterload事件呢,这个窗口是在打开关联表时才会open的?
老师们帮忙看看是是哪里错了。

afterload事件:

Dim nd As WinForm.TreeNode
Dim dt As DataTable
Dim sql As String
Dim je1,je2 As Double
Dim ndtext As String
Dim tr As  WinForm.TreeView = e.Form.Controls("TreeView1")

sql = CExp("sele ct * fr om t1 wh ere projectID =\'{0}\' ",_ProjectID)
dt = Functions.Execute("GetTableBySQL",sql)

tr.StopRedraw()
tr.Nodes.Clear

je2 = dt.compute("sum(g2float)")

tr.ResumeRedraw()

红色部分注释掉就不会提示了,为什么呢?

内部函数:GetTableBySQL
Dim cmd As New SQLCommand
Dim dt As DataTable
Dim dr As DataRow
cmd.C
cmd.CommandText = Args(0)
dt = cmd.ExecuteReader()
If dt.DataRows.Count >0 Then    
    Return dt
Else
    Return Nothing
End If
[此贴子已经被作者于2016/4/2 13:13:48编辑过]

--  作者:Hyphen
--  发布时间:2016/4/2 15:01:00
--  
说明项目打开的时候关联表已经打开了

Dim nd As WinForm.TreeNode
Dim dt As DataTable
Dim sql As String
Dim je1,je2 As Double
Dim ndtext As String
Dim tr As  WinForm.TreeView = e.Form.Controls("TreeView1")

sql = CExp("sele ct * fr om t1 wh ere projectID =\'{0}\' ",_ProjectID)
dt = Functions.Execute("GetTableBySQL",sql)

tr.StopRedraw()
tr.Nodes.Clear
If dt IsNot Nothing Then
    je2 = dt.compute("sum(g2float)")
End If
tr.ResumeRedraw()