下面的方法报了这么一个错误。是哪里出错了?
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()