Foxtable(狐表)用户栏目专家坐堂 → 数据类型 ntext 和 varchar 在 equal to 运算符中不兼容。


  共有1727人关注过本帖平板打印复制链接

主题:数据类型 ntext 和 varchar 在 equal to 运算符中不兼容。

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


加好友 发短信
等级:五尾狐 帖子:1165 积分:8129 威望:0 精华:0 注册:2015/3/30 10:44:00
数据类型 ntext 和 varchar 在 equal to 运算符中不兼容。  发帖心情 Post By:2017/2/16 18:19:00 [只看该作者]

下面的方法报了这么一个错误。是哪里出错了?
System.Data.SqlClient.SqlException: 数据类型 ntext 和 varchar 在 equal to 运算符中不兼容。
Public Function GetState1Refine(ByVal ddh As String, ByVal ddhh As String, ByVal wlbm As String, ByVal lhbbh As String, ByVal rjbb As String) As String
        Dim cnStr As String = "Data Source=172.16.11.201;Initial Catalog=songjiang;Integrated Security=False;User ID=sa;Password=bdcom103liujy;"
        Dim cn As New SqlClient.SqlConnection(cnStr)
        cn.Open()
        Dim filter As String = "1=1"
        If ddh = "null" Then
            filter &= " and 订单号 is null"
        ElseIf ddh > "" Then
            filter &= " and 订单号 = '" & ddh & "'"
        End If

       If ddhh = "null" Then
            filter &= " and 订单行号 is null"
        ElseIf ddhh > "" Then
            filter &= " and 订单行号 = '" & ddhh & "'"
        End If

        
        If wlbm = "null" Then
            filter &= " and 物料编码 is null"
        ElseIf wlbm > "" Then
            filter &= " and 物料编码 = '" & wlbm & "'"
        End If

        If lhbbh = "null" Then
            filter &= " and 两化表编号 is NULL"
        ElseIf lhbbh > "" Then
            filter &= " and 两化表编号 like '%" & lhbbh & "%'"
        End If
        
        If rjbb = "null" Then
            filter &= " and 软件版本 is null"
        ElseIf rjbb > "" Then
            filter &= " and 软件版本 = '" & rjbb & "'"
        End If

        Dim adapter As New SqlClient.SqlDataAdapter("sele ct * from [可用数量表] where " & filter, cn)

        Dim dt As New DataTable
        adapter.Fill(dt)
        cn.Close()

 回到顶部