Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共5 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]无法动态加载来自SQL SERVER的表

1楼
jgc1010 发表于:2009/3/16 12:45:00
我参考"动态加载数据的例子",想动态加载来自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编辑过]
2楼
狐狸爸爸 发表于:2009/3/16 12:48:00
我用的是内部表,而你用外部表,所有不能这样:

SELECT DISTINCT 分类号,保管期限,年度 From {订单}

而应该:

SELECT DISTINCT 分类号,保管期限,年度 From 订单
3楼
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, "","分类号", "保管期限","年度")
4楼
jgc1010 发表于:2009/3/16 13:44:00
SELECT DISTINCT 分类号,保管期限,年度 From tab_wjk 这段代码我测试过了,是没问题的.是不是其它代码有问题?
5楼
狐狸爸爸 发表于: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, "","分类号", "保管期限","年度")
共5 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02344 s, 2 queries.