以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  按钮筛选报错:无法在 System.String 和 System.Int32 上执行“=”操作。  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=120107)

--  作者:yetle
--  发布时间:2018/6/7 10:43:00
--  按钮筛选报错:无法在 System.String 和 System.Int32 上执行“=”操作。
筛选结果正常,但筛选完后报错:无法在 System.String 和 System.Int32 上执行“=”操作。另外我想在控件ComboBox上加fill的窗口数据表"生产明细_table1"的显示列和取值列内容是怎么加呢?

Dim stade As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker1")
Dim Endde As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker2")
\'Dim pd01 As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim cs01 As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim cs02 As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim cs03 As WinForm.ComboBox = e.Form.Controls("ComboBox3")
Dim cs04 As WinForm.ComboBox = e.Form.Controls("ComboBox4")

Dim dt As DataTable=DataTables("生产明细_table1")
Dim filter As String = "1=1"
With e.Form.Controls("DateTimePicker1")
If .Value IsNot Nothing Then
   If stade.text >"" Then
     Filter = Filter & " And "
   End If
\'      filter= filter & " and a.InDate >=\'" & stade.text & "\'"
       filter= filter & "[制单日期] >=\'" & stade.text & "\'"
End If
End With

With e.Form.Controls("DateTimePicker2")
If .Value IsNot Nothing Then
    If  Endde.text>"" Then
      Filter = Filter & " And "
    End If
\'     filter=filter & " and a.InDate <= \'" & Endde.text & "\'"
       filter=filter & "[制单日期] <= \'" & Endde.text & "\'"
End If
End  With

With e.Form.Controls("ComboBox1")
If .Value IsNot Nothing Then
    If cs01.text>"" Then
      Filter = Filter & " And "
    End If
       filter=filter & "[物供号] = \'" & cs01.text & "\'"
End If
End  With

With e.Form.Controls("ComboBox2")
If .Value IsNot Nothing Then
    If cs02.text>"" Then
      Filter = Filter & " And "
    End If
       filter=filter & "[类别] = \'" & cs02.text & "\'"
End If
End  With

With e.Form.Controls("ComboBox3")
If .Value IsNot Nothing Then
    If cs03.text>"" Then
      Filter = Filter & " And "
    End If
       filter=filter & "[厂号] = \'" & cs03.text & "\'"
End If
End  With

With e.Form.Controls("ComboBox4")
If .Value IsNot Nothing Then
    If cs04.text>"" Then
      Filter = Filter & " And "
    End If
       filter=filter & "[客款号] = \'" & cs04.text & "\'"
End If
End  With


If Filter > "" Then
\'     dt.LoadFilter=filter
    Tables("生产明细_table1").Filter=filter
\'     dt.Load()
End If


是这两段建立关联的代码引起的,我注释掉后,筛选完后就不会报错:无法在 System.String 和 System.Int32 上执行“=”操作。

\' Relations.Add("CN",DataTables("生产明细_table1").DataCols("订单号"),DataTables("产能").DataCols("订单号"))

\' With Tables("生产明细_table1")
\' Dim cn As Table = Tables("产能")
\'     If .Current Is Nothing Then
\'         cn.Filter = "False"
\'     Else
\'         cn.Filter = "订单号 = " & .Current("订单号")
\'     End If
\' End With



\' Relations.Add("pd",DataTables("生产明细_table1").DataCols("订单号"),DataTables("排单状态").DataCols("订单号"))

\' With Tables("生产明细_table1")
\' Dim pd As Table = Tables("排单状态")
\'     If .Current Is Nothing Then
\'         pd.Filter = "False"
\'     Else
\'         pd.Filter = "订单号 = " & .Current("订单号")
\'     End If
\' End With
[此贴子已经被作者于2018/6/7 11:16:52编辑过]

--  作者:有点甜
--  发布时间:2018/6/7 11:17:00
--  

1、贴出你currentChanged事件代码;

 

2、参考 http://www.foxtable.com/webhelp/scr/0926.htm

 


--  作者:yetle
--  发布时间:2018/6/7 11:51:00
--  
With Tables("生产明细_table1")
Dim pd As Table = Tables("排单状态")
    If .Current Is Nothing Then
        pd.Filter = "False"
    Else
        pd.Filter = "订单号 = " & .Current("订单号")
    End If
End With

With Tables("生产明细_table1")
Dim cn As Table = Tables("产能")
    If .Current Is Nothing Then
        cn.Filter = "False"
    Else
        cn.Filter = "订单号 = " & .Current("订单号")
    End If
End With

--  作者:有点甜
--  发布时间:2018/6/7 11:53:00
--  

改成

 

pd.Filter = "订单号 = \'" & .Current("订单号") & "\'"