Foxtable(狐表)用户栏目专家坐堂 → SQL查询


  共有3686人关注过本帖树形打印复制链接

主题:SQL查询

帅哥哟,离线,有人找我吗?
巷弄太过弯曲
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:219 积分:1800 威望:0 精华:0 注册:2019/2/16 10:17:00
SQL查询  发帖心情 Post By:2019/11/12 13:49:00 [只看该作者]

老师,请问怎么把这段筛选代码拼接到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() '自动列宽


 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110574 积分:562760 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By: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()

 回到顶部