以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  求助关于数据行内容包含的查找问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=9050)

--  作者:yankunhao
--  发布时间:2011/1/23 16:10:00
--  求助关于数据行内容包含的查找问题

   我在一个表的DataColChanged事件中写下面的代码,想在“原材料基础数据表”里查找出“料品名称”等于当前行的“料品名称”且“通用范围”里包含有当前表的“成品名称”的行,如果找到就将其“料品编码”输入到当前表中,请问这个代码为什么不行呢?如何做才科学呢?

 

Select Case e.DataCol.Name

Case "成品名称"
        If e.DataRow.IsNull("成品名称") = False Then
            Dim s As String =e.DataRow("成品名称")
            Dim drs As List(Of DataRow)
            drs = DataTables("原材料基础数据表").Select("[料品名称] = \'" & e.DataRow("料品名称") & "\'")
            For Each dr As DataRow In drs
                If dr("通用范围").IndexOf(s) > 0 Then
                    e.DataRow("料品编码")= dr("料品编码")
                End If
            Next
        End If
End Select


--  作者:yankunhao
--  发布时间:2011/1/23 16:17:00
--  

现在这样就可以了,请问大家还有其他好的方案吗?

Select Case e.DataCol.Name

Case "成品名称"
        If e.DataRow.IsNull("成品名称") = False Then
            Dim s As String =e.DataRow("成品名称")
            Dim drs As List(Of DataRow)
            drs = DataTables("原材料基础数据表").Select("[料品名称] = \'" & e.DataRow("料品名称") & "\'")
            For Each dr As DataRow In drs
                If dr("通用范围").IndexOf(s) > -1 Then
                    e.DataRow("料品编码")= dr("料品编码")
                End If
            Next
        End If
End Select

 


--  作者:狐狸爸爸
--  发布时间:2011/1/23 16:47:00
--  

可以用Like,具体参考:

 

http://help.foxtable.com/topics/0102.htm