以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  SQL查询  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=143044)

--  作者:巷弄太过弯曲
--  发布时间:2019/11/12 13:49:00
--  SQL查询
老师,请问怎么把这段筛选代码拼接到SQL语句中 也能做到筛选功能
Dim Filte r As String
With e.For m.Co ntrols("供应商")
    If .Value IsNot Nothing Then
        Fil ter = "供应商 = \'" & .Value & "\'"
    End If
End With


If Filter > "" Then
    Tables("窗口2_Table1").Filter = Filter
End If

SQL语句:
Dim djbh As WinFor m.ComboBox = e.Form.Controls("单据编号")
Dim cmd As New SQ LCommand
Dim dt As DataTable
Dim cmb As WinForm.ComboBox
cmd.Conn ecti
cmd.Comma ndText = "S EL EC T fbillno as 单据编号,{t_Supplier}.Fname as 供应商 ,{POOrder}.fdate as 日期 ,{t_Department}.FName as 部门,{t_ICItem}.fname as 物料名称,{t_ICItem}.FModel as 规格型号, " & 
"{t_MeasureUnit}.fname As 单位 ,{t_Currency}.Fname As 币别,{POOrderEntry}.FQty As 数量,{t_emp}.FName As 业务员, b.fname As 制单人 ,{t_user}.fname As 审核人, {POOrder}.FCheckDate As 审核时间  " &
  "From ({POOrder} left join {t_Supplier} on {POOrder}.FSupplyID = {t_Supplier}.FItemID left join {t_Department} on {POOrder}.FDeptID = {t_Department}.FItemID " &
"left join {POOrderEntry} on {POOrder}.FInterID = {POOrderEntry}.FInterID inner join {t_ICItem} on {POOrderEntry}.FItemID = {t_ICItem}.FItemID inner join {t_MeasureUnit} on {t_ICItem}.FUnitID = {t_MeasureUnit}.FMeasureUnitID " &
 "inner join {t_emp} on {POOrder}.FEmpID = {t_emp}.fitemid inner join {t_Currency} on {POOrder}.FCurrencyID = {t_Currency}.FCurrencyID left join {t_User} on {POOrder}.fcheckerid = {t_User}.FUserID) " &
"left join {t_User} b on {POOrder} .FBillerID = b .FUserID  WHERE fbillno = \'" & djbh.Value & "\'" 
 
dt = cmd.ExecuteReader()
cmb = e.Form.Controls("供应商")
cmb.ComboList= dt.GetComboListString("供应商")
cmb = e.Form.Controls("单据编号")
cmb.ComboList= dt.GetComboListString("单据编号")
cmb = e.Form.Controls("物料名称")
cmb.ComboList= dt.GetComboListString("物料名称")
cmb = e.Form.Controls("部门")
cmb.ComboList= dt.GetComboListString("部门")
cmb = e.Form.Controls("规格型号")
cmb.ComboList= dt.GetComboListString("规格型号")

Tables("窗口2_Table1").DataSource = dt
Tables("窗口2_Table1").DataTable.DataCols("数量").Decimals = 1
Tables("窗口2_Table1").DataTable.DataCols("数量").SetFormat("0.0")
Tables("窗口2_Table1").AutoSizeCols() \'自动列宽


--  作者:有点蓝
--  发布时间:2019/11/12 14:22:00
--  
D left join {t_User} on {POOrder}.fcheckerid = {t_User}.FUserID) " &
"left join {t_User} b on {POOrder} .FBillerID = b .FUserID  WHERE fbillno = \'" & djbh.Value & "\' and 供应商 = \'" & .Value & "\'" 
 
dt = cmd.ExecuteReader()