Public Function Detailedquery(ByVal scddhm As String, ByVal gdhh As String, ByVal wlbm As String, ByVal kwlb As String, ByVal startdate As String, ByVal enddate 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 state As String = ""
Dim filter As String = "1=1"
If scddhm = "" And gdhh = "" And wlbm = "" And kwlb = "" And startdate = "" And enddate = "" Then
Dim adapter1 As New SqlClient.SqlDataAdapter("s elect * from [可用数量表]", cn)
Dim dt As New DataTable
adapter1.Fill(dt)
cn.Close()
For Each dr As DataRow In dt.Rows
state &= "生产订单号码:" & dr("生产订单号码") & "工单行号:" & dr("工单行号") & "物料编码:" & dr("物料编码") & "库位类别:" & dr("库位类别") & "入库时间:" & dr("入库时间") & "|"
Next
Return state
Else
If scddhm <> "" Then
filter &= "and 生产订单号码 = '" & scddhm & "' "
Else
End If
If gdhh <> "" Then
filter &= "and 工单行号 = '" & gdhh & "'"
End If
If wlbm <> "" Then
filter &= "and 物料编码 = '" & wlbm & "'"
End If
If kwlb <> "" Then
filter &= "库位类别 = '" & kwlb & "'"
End If
If startdate <> "" Then
filter &= "入库时间 >= '" & startdate & "'"
End If
If enddate <> "" Then
filter &= "入库时间 <= '" & enddate & "'"
End If
Dim adapter As New SqlClient.SqlDataAdapter("s elect * from [可用数量表] where filter", cn)
Dim dt As New DataTable
adapter.Fill(dt)
cn.Close()
For Each dr As DataRow In dt.Rows
state &= "生产订单号码:" & dr("生产订单号码") & "工单行号:" & dr("工单行号") & "物料编码:" & dr("物料编码") & "库位类别:" & dr("库位类别") & "入库时间:" & dr("入库时间") & "|"
Next
Return state
End If
End Function
报这个错误:System.Data.SqlClient.SqlException: 在应使用条件的上下文(在 'filter' 附近)中指定了非布尔类型的表达式。