以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]无法动态加载来自SQL SERVER的表 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=2112) |
-- 作者:jgc1010 -- 发布时间:2009/3/16 12:45:00 -- [求助]无法动态加载来自SQL SERVER的表 我参考"动态加载数据的例子",想动态加载来自SQL SERVER的表:tab_wjk.但是主窗口的afterload中的代码,测试时报错,请问是什么原因.请帮我检查一下错在哪里?还是外部表的代码不一样? 窗口afterload代码如下: Dim cmd As New SQLCommand Dim dt As DataTable cmd.CommandText = "SELECT DISTINCT 分类号,保管期限,年度 From {tab_wjk}" dt = cmd.ExecuteReader() Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1") trv.BuildDataTree(dt, "","分类号", "保管期限","年度") NodeMouseDoubleClick的代码如下: Dim Value()As String Dim Filter As string Value = e.Node.FullPath.Split("\\") Select Case e.Node.Level Case 0 Filter ="[分类号] = \'" & Value(0) & "\'" Case 1 Filter ="[分类号] = \'" & Value(0) & "\' And [保管期限] = \'" & Value(1) & "\'" Case 2 Filter ="[分类号] = \'" & Value(0) & "\' And [保管期限] = \'" & Value(1) & "\' And [年度] = \'" & Value(2) & "\'" End Select DataTables("tab_wjk").LoadFilter = Filter DataTables("tab_wjk").Load() [此贴子已经被作者于2009-3-16 13:26:34编辑过]
|
-- 作者:狐狸爸爸 -- 发布时间:2009/3/16 12:48:00 -- 我用的是内部表,而你用外部表,所有不能这样: SELECT DISTINCT 分类号,保管期限,年度 From {订单} 而应该: SELECT DISTINCT 分类号,保管期限,年度 From 订单 |
-- 作者:jgc1010 -- 发布时间:2009/3/16 13:31:00 -- 窗口afterload代码改成如下还是报错: Dim cmd As New SQLCommand Dim dt As DataTable cmd.CommandText = "SELECT DISTINCT 分类号,保管期限,年度 From tab_wjk" dt = cmd.ExecuteReader() Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1") trv.BuildDataTree(dt, "","分类号", "保管期限","年度") |
-- 作者:jgc1010 -- 发布时间:2009/3/16 13:44:00 -- SELECT DISTINCT 分类号,保管期限,年度 From tab_wjk 这段代码我测试过了,是没问题的.是不是其它代码有问题? |
-- 作者:狐狸爸爸 -- 发布时间:2009/3/16 15:43:00 -- 你用的是外部数据源,必须给SQLCommand指定数据源名称,否则肯定出错: Dim cmd As New SQLCommand Dim dt As DataTable cmd.ConnectionName = "数据源名称" cmd.CommandText = "SELECT DISTINCT 分类号,保管期限,年度 From tab_wjk" dt = cmd.ExecuteReader() Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1") trv.BuildDataTree(dt, "","分类号", "保管期限","年度") |