以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  菜单设计  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=77715)

--  作者:huazhencong
--  发布时间:2015/11/24 10:07:00
--  菜单设计
我按照视频教程上写了如下代码:查找时却出现错误提示,请问咋的回事啊!
Dim strfind As RibbonMenu.TextBox = RibbonTabs("Common")("功能组1")("工具栏1")("strfind")
Dim val As String = strfind.text
With CurrentTable
    Dim nm As String = .Cols(.Colsel).name
    Dim index As Integer = .FindRow(nm & " = \'" & val & "\' ",.position + 1,True)
    If index >= 0 Then
        .position = index
    End If
End With

--  作者:大红袍
--  发布时间:2015/11/24 10:09:00
--  
报什么错?贴出错误。
--  作者:huazhencong
--  发布时间:2015/11/24 10:14:00
--  
.NET Framework 版本:2.0.50727.5485
Foxtable 版本:2015.11.2.1
错误所在事件:菜单,find,Click
详细错误信息:
System.Data.EvaluateException: 无法在 System.Int32 和 System.String 上执行“=”操作。
   在 System.Data.BinaryNode.SetTypeMismatchError(Int32 op, Type left, Type right)
   在 System.Data.BinaryNode.BinaryCompare(Object vLeft, Object vRight, StorageType resultType, Int32 op, CompareInfo comparer)
   在 System.Data.BinaryNode.EvalBinaryOp(Int32 op, ExpressionNode left, ExpressionNode right, DataRow row, DataRowVersion version, Int32[] recordNos)
   在 System.Data.BinaryNode.Eval(DataRow row, DataRowVersion version)
   在 System.Data.Select.AcceptRecord(Int32 record)
   在 System.Data.Select.GetLinearFilteredRows(Range range)
   在 System.Data.Select.SelectRows()
   在 System.Data.DataTable.Select(String filterExpression, String sort)
   在 Foxtable.Table.FindRow(String Expression, Int32 RowStart, Boolean Wrap)
   在 UserCode.AMovPVnsjQ4X0W1E9(RibbonButtonEventArgs e)

--  作者:大红袍
--  发布时间:2015/11/24 10:20:00
--  

这样改一下

 

    Dim index As Integer = .FindRow("Convert(" & nm & ",\'System.String\') = \'" & val & "\' ",.position + 1,True)


--  作者:huazhencong
--  发布时间:2015/11/24 10:29:00
--  
老师,虽然不报错,可是出不来效果喔!
--  作者:大红袍
--  发布时间:2015/11/24 10:33:00
--  
代码没有问题,查不到,就是你列没有选对或者没有对应的数据。
--  作者:huazhencong
--  发布时间:2015/11/24 11:23:00
--  
老师,我知道问题出在哪里呢,就是您说的,是我要选中要查找的数据的列才行,谢谢啦!