Foxtable(狐表)用户栏目专家坐堂 → 条件


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

主题:条件

帅哥哟,离线,有人找我吗?
huhu
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1188 积分:8282 威望:0 精华:0 注册:2015/3/30 10:44:00
条件  发帖心情 Post By:2016/12/23 12:41:00 [只看该作者]

 Public Function GetState2Refine(ByVal ddh As String, ByVal ddhh As String, ByVal wlbm As String, ByVal rjbb As String, ByVal lhbbh As String) As String
        Dim cnStr As String = "Data Source=(local);Initial Catalog=songjiang;Integrated Security=False;User ID=sa;Password=bdcom103liujy;"
        Dim cn As New SqlClient.SqlConnection(cnStr)
        cn.Open()
        Dim adapter As New SqlClient.SqlDataAdapter("sel ect * from [可用数量表]  where 订单号 <> '" & ddh & "' and 订单行号 <> '" & ddhh & "' and 物料编码 = '" & wlbm & "' and 软件版本 = '" & rjbb & "' and 两化表编号 = '" & lhbbh & "'", cn)
        Dim dt As New DataTable
        adapter.Fill(dt)
        cn.Close()



当输入的订单号和订单行号为空
"sel ect * from [可用数量表]  where 物料编码 = '" & wlbm & "' and 软件版本 = '" & rjbb & "' and 两化表编号 = '" & lhbbh & "'"
当输入的订单号和订单行号都不为空时
"sel ect * from [可用数量表]  where 订单号 <> '" & ddh & "' and 订单行号 <> '" & ddhh & "' and 物料编码 = '" & wlbm & "' and 软件版本 = '" & rjbb & "' and 两化表编号 = '" & lhbbh & "'"
在下面的语句怎么写才能满足上面2个条件。
Dim adapter As New SqlClient.SqlDataAdapter("sele ct * from [可用数量表]  where 订单号 <> '" & ddh & "' and 订单行号 <> '" & ddhh & "' and 物料编码 = '" & wlbm & "' and 软件版本 = '" & rjbb & "' and 两化表编号 = '" & lhbbh & "'", cn)

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


加好友 发短信
等级:管理员 帖子:47526 积分:251577 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2016/12/23 12:54:00 [只看该作者]

Dim adapter SqlClient.SqlDataAdapter
if ddhh =""  then
    adapter = New SqlClient.SqlDataAdapter("sele ct * from [可用数量表]  where  物料编码 = '" & wlbm & "' and 软件版本 = '" & rjbb & "' and 两化表编号 = '" & lhbbh & "'", cn)
else
    adapter = New SqlClient.SqlDataAdapter("sele ct * from [可用数量表]  where 订单号 <> '" & ddh & "' and 订单行号 <> '" & ddhh & "' and 物料编码 = '" & wlbm & "' and 软件版本 = '" & rjbb & "' and 两化表编号 = '" & lhbbh & "'", cn)
endif


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


加好友 发短信
等级:五尾狐 帖子:1188 积分:8282 威望:0 精华:0 注册:2015/3/30 10:44:00
  发帖心情 Post By:2016/12/23 13:49:00 [只看该作者]

 Dim adapter As SqlClient.SqlDataAdapter
        If ddh = "" And ddhh = "" Then
            adapter = New SqlClient.SqlDataAdapter("sel ect * from [可用数量表]  where  物料编码 = '" & wlbm & "' and 软件版本 = '" & rjbb & "' and 两化表编号.contains( '" & lhbbh & "')", cn)
        Else
            adapter = New SqlClient.SqlDataAdapter("sel ect * from [可用数量表]  where 订单号 <> '" & ddh & "' and 订单行号 <> '" & ddhh & "' and 物料编码 = '" & wlbm & "' and 软件版本 = '" & rjbb & "' and 两化表编号.contains('" & lhbbh & "')", cn)
        End If
        Dim dt As New DataTable
        adapter.Fill(dt)
        cn.Close()

两化表编号.contains('" & lhbbh & "')这么写是不是不对呢?

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


加好友 发短信
等级:超级版主 帖子:113838 积分:579781 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2016/12/23 14:16:00 [只看该作者]

and 两化表编号 like '%" & lhbbh & "%'", cn)

 回到顶部