以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  MYSQL目录对报错?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=188322)

--  作者:lin98
--  发布时间:2023/9/14 10:37:00
--  MYSQL目录对报错?
Dim cmd As New SQ-LCommand
Dim
 dt As DataTable
cmd
.CommandText = "SELEC-T DISTINCT Year(日期) As , Month(日期) As 产品 From 订单"
dt
 = cmd.ExecuteReader()
Dim
 trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv
.BuildTree(dt, "年|月|产品")

报错,

Microsoft Jet 数据库引擎找不到输入表或查询 \'订单\'。 确定它是否存在,以及它的名称的拼写是否正确。

--  作者:有点蓝
--  发布时间:2023/9/14 11:14:00
--  
MYSQL只能使用第三方组件
--  作者:lin98
--  发布时间:2024/2/1 21:56:00
--  
Dim db = HySq-l.DataBaseFactory.CreateDatabase("myjx") \'
Dim Sq-l2 = "Selec-t a.采购单号,a.产品编号, a.品名, a.交货日期,b.供方, b.采购日期, b.供方,b.制单人,b.UserID  From   cgm_tb as  a   Inner Join    cgz_tb  as  b On (a.采购单号 = b.采购单号) " & _
"where    (b.制单人= \'" & _Username & "\'  or   b.UserID in (\'" & s.Replace(",", "\',\'") & "\'))  " & _
"And  b.采购日期 >= \'" & StartDate & "\' And b.采购日期 <= \'" & EndDate & "\' "
Dim dt2 As system.data.DataTable = db.ExecuteDataSet(Sq-l2).Tables(0)
Dim t2 As Table = e.Form.Controls("Table1").Table
t2.datasource = dt2.Copy
t2.AllowEdit = False \'


\'目录树-按日期
Dim Sq-l3 = "SELEC-T DISTINCT Year(采购日期) As 年, Month(采购日期) As 月,采购单号,采购日期, 供方 From cgz_tb"
Dim dt3 As system.data.DataTable = db.ExecuteDataSet(Sq-l3).Tables(0)
Dim t3 As Table = e.Form.Controls("Table2").Table
t3.datasource = dt3.Copy
Dim trv3 As WinForm.TreeView = e.Form.Controls("TreeView4")
trv3.BuildTree("查询窗口_Table2", "年|月|供方")




Dim dr As DataRow = e.Node.DataRow \'获取生成此节点的行
Dim Filter As String
Dim Year As Integer = dr("年")
Dim Month As Integer = dr("月")
Dim Product As String = dr("供方")
Select Case e.Node.Level
    Case 0
        Filter = "Year(采购日期) = " & Year
    Case 1
        Filter = "Year(采购日期) = " & Year & " And Month(采购日期) = " & Month
    Case 2
        Filter = "Year(采购日期) = " & Year & " And Month(采购日期) = " & Month & " And 供方 = \'" & Product & "\'"
End Select

\'DataTables("查询窗口_Table2").LoadFilter = Filter
\'DataTables("查询窗口_Table2").Load()
DataTables("查询窗口_Table1").LoadFilter = Filter
DataTables("查询窗口_Table1").Load()

单击目录树节点没反映,如何解决?


--  作者:lin98
--  发布时间:2024/2/1 22:08:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:11.jpg
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2024/2/1 22:40:00
--  
第三方数据库不能使用内置的Load加载数据的,只能像第一段代码一样绑定表控件,生成的条件必须符合mysql的语法

……
    Case 2
        Filter = "Year(采购日期) = " & Year & " And Month(采购日期) = " & Month & " And 供方 = \'" & Product & "\'"
End Select
Dim db = HySq-l.DataBaseFactory.CreateDatabase("myjx") \'
Dim Sq-l2 = "Selec-t a.采购单号,a.产品编号, a.品名, a.交货日期,b.供方, b.采购日期, b.供方,b.制单人,b.UserID  From   cgm_tb as  a   Inner Join    cgz_tb  as  b On (a.采购单号 = b.采购单号) " & _
"where    (b.制单人= \'" & _Username & "\'  or   b.UserID in (\'" & s.Replace(",", "\',\'") & "\'))  and " & Filter
Dim dt2 As system.data.DataTable = db.ExecuteDataSet(Sq-l2).Tables(0)
Dim t2 As Table = e.Form.Controls("Table1").Table
t2.datasource = dt2.Copy
t2.AllowEdit = False \'