以文本方式查看主题

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

--  作者:刘林
--  发布时间:2020/6/29 8:10:00
--  正常代码突然出现未将对象设置。。。
e.Form.BaseForm.windowstate = 2
Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.connectionname = 
Dim ccb1 As WinForm.CheckedComboBox= e.Form.Controls("checkedcombobox1")
If js.Contains("区业务主管")
    cmd.CommandText = "SE/ECT DISTINCT 考试名称,单位名称,年级,班级  From {成绩}  where 学段 =\'初中\' order by 考试名称 desc "
    ccb1.ComboList = DataTables("考试名称").GetComboListString("考试名称","学段 = \'初中\'","考试名称 desc")
    Dim dt1 As DataTable = DataTables("考试名称")
    Dim cmb4 As WinForm.ComboBox = e.form.Controls("ComboBox1")
    Dim cmb5 As WinForm.ComboBox = e.form.Controls("ComboBox5")
    cmb4.ComboList = dt1.GetComboListString("考试名称","学段=\'初中\'","考试名称 desc")
    cmb5.ComboList = dt1.GetComboListString("考试名称","学段=\'初中\'","考试名称 desc")
    E.Form.Controls("BUTTON13").Visible=True    
Else
    cmd.CommandText = "SE/ECT DISTINCT 考试名称,单位名称,年级,班级,学段  From {成绩}  where 单位名称 = \'" & _usergroup & "\' and 学段 = \'初中\' and 考试名称 in (Sel    ect 考试名称 From {考试名称} where 是否可看 = 1 and 学段=\'初中\') order by 考试名称 desc"
    Dim dt1 As DataTable = DataTables("考试名称")
    Dim cmb4 As WinForm.ComboBox = e.form.Controls("ComboBox1")
    Dim cmb5 As WinForm.ComboBox = e.form.Controls("ComboBox5")
    ccb1.ComboList = DataTables("考试名称").sqlGetComboListString("考试名称","学段 = \'初中\' and 暂不统计=0","考试名称 desc")
    cmb4.ComboList = dt1.sqlGetComboListString("考试名称","学段=\'初中\' and 是否可看 = 1","考试名称 desc")
    cmb5.ComboList = dt1.sqlGetComboListString("考试名称","学段=\'初中\' and 是否可看 = 1","考试名称 desc")    
End If
messagebox.show("问题1")
dt = cmd.ExecuteReader()
messagebox.show("问题2")
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
messagebox.show("问题3")
trv.BuildTree(dt,"考试名称|单位名称|年级|班级", "" ,"考试名称 desc")
messagebox.show("问题4")



老师,项目没有改过(至少这个代码没改过),以前都是好的,今天打开项目运行这个代码时出现:未将对象引用设置到对象的实例。检到问题3要显后出提示,但没看出问题3和问题4有什么问题,关键是确实没改过,请老师指点,谢谢

--  作者:lgzhao
--  发布时间:2020/6/29 8:14:00
--  
我猜是不是你的DT生成的有问题,没有生成列出来。是不是你最近升版了程序? 图片点击可在新窗口打开查看
--  作者:刘林
--  发布时间:2020/6/29 8:42:00
--  
  "SE/ECT DISTINCT 考试名称,单位名称,年级,班级  From {成绩}  where 学段 =\'初中\' order by 考试名称 desc "
单独执行sql语句生成都没有问题

--  作者:有点蓝
--  发布时间:2020/6/29 8:50:00
--  
这样测试有没有问题?

trv.BuildTree(dt,"考试名称")