Foxtable(狐表)用户栏目专家坐堂 → [求助]提示sql语句执行错误


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

主题:[求助]提示sql语句执行错误

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


加好友 发短信
等级:幼狐 帖子:92 积分:1856 威望:0 精华:0 注册:2014/4/11 21:10:00
[求助]提示sql语句执行错误  发帖心情 Post By:2018/10/24 14:10:00 [显示全部帖子]

Dim Filter As String

With e.Form.Controls("txtkh")

    If .Value IsNot Nothing Then

        Filter = "Customer like '%" & .Value & "%'"

    End If

End With

With e.Form.Controls("txtcp")

    If .Value IsNot Nothing Then

        If Filter > "" Then

            Filter = Filter & " And "

        End If

        Filter = Filter & "Product like '%" & .Value & "%'"

    End If

End With

With e.Form.Controls("txtgdh")

    If .Value IsNot Nothing Then

        If Filter >"" Then

            Filter = Filter & " And "

        End If

        Filter = Filter & "PNum like '%" & .Value & "%'"

    End If

End With

With e.Form.Controls("txthth")

    If .Value IsNot Nothing Then

        If Filter >"" Then

            Filter = Filter & " And "

        End If

        Filter = Filter & "ContractNum like '%" & .Value & "%'"

    End If

End With

With e.Form.Controls("txtddh")

    If .Value IsNot Nothing Then

        If Filter >"" Then

            Filter = Filter & " And "

        End If

        Filter = Filter & "OrderNum like '%" & .Value & "%'"

    End If

End With

With e.Form.Controls("cmbywy")

    If .Value IsNot Nothing Then

        If Filter > "" Then

            Filter = Filter & " And "

        End If

        Filter = Filter & "Sales like '%" & .Value & "%'"

    End If

End With


With e.Form.Controls("startdate")

    If .Value IsNot Nothing Then

        If Filter >"" Then

            Filter = Filter & " And "

        End If

        Filter = Filter & "InDate >= '" & .Value & "'"

    End If

End With

With e.Form.Controls("enddate")

    If .Value IsNot Nothing Then

        If Filter >"" Then

            Filter = Filter & " And "

        End If

        Filter = Filter & "InDate <= '" & .Value & "'"

    End If

End With

If Filter > "" Then

DataTables("工单资料").Fill("Select {PNumPrintInfo}.ID,{PNumPrintInfo}.PNum,{PNumPrintInfo}.Product,PartsName,MPStyle,PaperName,PrintScale,PrintColor,PrintColorDes,PCount,LCount,TotalCount,DevName,MScale,MPCount,Customer,ContractNum,InDate,OrderNum,Sales Fro m {PNumPrintInfo} Inner JOIN {PNumSumInfo} ON {PNumSumInfo}.[PNum] = {PNumPrintInfo}.[PNum] Where Filter Order By InDate desc", "xunyue", True)


End If




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

[此贴子已经被作者于2018/10/24 17:16:31编辑过]

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


加好友 发短信
等级:幼狐 帖子:92 积分:1856 威望:0 精华:0 注册:2014/4/11 21:10:00
  发帖心情 Post By:2018/10/24 15:36:00 [显示全部帖子]

好的,谢谢

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


加好友 发短信
等级:幼狐 帖子:92 积分:1856 威望:0 精华:0 注册:2014/4/11 21:10:00
  发帖心情 Post By:2018/10/24 15:45:00 [显示全部帖子]

With e.Form.Controls("txtcp") '产品名称

    If .Value IsNot Nothing Then

        If Filter > "" Then

            Filter = Filter & " And "

        End If

        Filter = Filter & "Product like '%" & .Value & "%'"

    End If

End With

With e.Form.Controls("txtgdh") '工单号

    If .Value IsNot Nothing Then

        If Filter >"" Then

            Filter = Filter & " And "

        End If

        Filter = Filter & "PNum like '%" & .Value & "%'"

    End If

End With


With e.Form.Controls("txtddh") '订单号

    If .Value IsNot Nothing Then

        If Filter >"" Then

            Filter = Filter & " And "

        End If

        Filter = Filter & "OrderNum like '%" & .Value & "%'"

    End If

End With



查询条件输入订单号,工单号,产品名称 后又会提示sql语句执行错误。 不知道哪里还要修改?


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


加好友 发短信
等级:幼狐 帖子:92 积分:1856 威望:0 精华:0 注册:2014/4/11 21:10:00
  发帖心情 Post By:2018/10/24 16:26:00 [显示全部帖子]

是的 sql 数据源
这个代码试了还是不行

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


加好友 发短信
等级:幼狐 帖子:92 积分:1856 威望:0 精华:0 注册:2014/4/11 21:10:00
  发帖心情 Post By:2018/10/24 17:14:00 [显示全部帖子]

With e.Form.Controls("txtcp")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "convert(varchar(200),Product) like '%" & .Value & "%'"
    End If
End With
With e.Form.Controls("txtgdh")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "convert(varchar(200),PNum) like '%" & .Value & "%'"
    End If
End With
With e.Form.Controls("txtddh")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "OrderNum like '%" & .Value & "%'"
    End If
End With

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


加好友 发短信
等级:幼狐 帖子:92 积分:1856 威望:0 精华:0 注册:2014/4/11 21:10:00
  发帖心情 Post By:2018/10/24 17:32:00 [显示全部帖子]

With e.Form.Controls("txtcp")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "Product like '%" & .Value & "%'"
    End If
End With
With e.Form.Controls("txtgdh")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "PNum like '%" & .Value & "%'"
    End If
End With
With e.Form.Controls("txtddh")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "OrderNum like '%" & .Value & "%'"
    End If
End With


图片点击可在新窗口打开查看此主题相关图片如下:梦之队截图未命名.jpg
图片点击可在新窗口打开查看


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


加好友 发短信
等级:幼狐 帖子:92 积分:1856 威望:0 精华:0 注册:2014/4/11 21:10:00
  发帖心情 Post By:2018/10/24 22:38:00 [显示全部帖子]

有一个条件可以了,不报错。
但是下面这两个条件输入数据还是不行
With e.Form.Controls("txtcp")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "convert(varchar(200),Product) like '%" & .Value & "%'"
    End If
End With
With e.Form.Controls("txtgdh")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "convert(varchar(200),PNum) like '%" & .Value & "%'"
    End If
End With


DataTables("工单资料").Fill("Select {PNumPrintInfo}.ID,{PNumPrintInfo}.PNum,{PNumPrintInfo}.Product,PartsName,MPStyle,PaperName,PrintScale,PrintColor,PrintColorDes,PCount,LCount,TotalCount,DevName,MScale,MPCount,Customer,ContractNum,InDate,OrderNum,Sales Fro m {PNumPrintInfo} Inner JOIN {PNumSumInfo} ON {PNumSumInfo}.[PNum] = {PNumPrintInfo}.[PNum] Where Filter Order By InDate desc", "xunyue", True)




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


加好友 发短信
等级:幼狐 帖子:92 积分:1856 威望:0 精华:0 注册:2014/4/11 21:10:00
  发帖心情 Post By:2018/10/24 22:53:00 [显示全部帖子]

解决了,改成这个
With e.Form.Controls("txtcp")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "convert(varchar(200),{PNumSumInfo}.Product) like '%" & .Value & "%'"
    End If
End With
With e.Form.Controls("txtgdh")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "convert(varchar(200),{PNumSumInfo}.PNum) like '%" & .Value & "%'"
    End If
End With


 回到顶部