vb C# 中 datatable 模糊查询如何写。like语句 。急急急。

gongyan0910 2013-08-20 03:16:48
现在我的代码是这样的。红色标注部分是我想实现模糊查询,但是这样写不对。如下:
''' <summary>
''' </summary>
''' <param name="B3cdin"></param>
''' <returns></returns> Where tbl.B1CD Like B3cdin + "%" _
''' <remarks></remarks>
Public Function GetListDataWithB3cd(ByVal B3cdin As String) As wData.WppDataSet.VTMTN035MST_01DataTable
Dim result As New WppDataSet.VTMTN035MST_01DataTable
If String.IsNullOrEmpty(B3cdin) Then
Dim filter = _
From tbl In getCommonDataSet().VTMTN035MST_01.AsEnumerable() _
Order By _
tbl.TENPOCD, _
tbl.B3KBN, _
tbl.GRAPH, _
tbl.B3CD

For Each row2 In filter
result.ImportRow(row2)
Next
Else
Dim filter = _
From tbl In getCommonDataSet().VTMTN035MST_01.AsEnumerable() _
Where tbl.B1CD Like B3cdin + "%" _ Order By _
tbl.TENPOCD, _
tbl.B3KBN, _
tbl.GRAPH, _
tbl.B3CD

For Each row2 In filter
result.ImportRow(row2)
Next
End If
Return result
End Function
...全文
329 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
gongyan0910 2013-08-26
  • 打赏
  • 举报
回复
引用 2 楼 whitewolf123 的回复:
tbl.B1CD字段是字符类型吗?是的就要这样写 Where tbl.B1CD Like "'"+B3cdin + "%'" 这是linq吗?我不是很了解这个,你试试看吧。
这样不行,我换了种方式现在可以了。谢谢你的回答。 dim datarow() as WppDataSet.WTMTN035MST_01Row = getCommonDataSet().Select("B1CD like '" + B3cdin +"%'")
vicanary 2013-08-21
  • 打赏
  • 举报
回复
tbl.B1CD字段是字符类型吗?是的就要这样写 Where tbl.B1CD Like "'"+B3cdin + "%'" 这是linq吗?我不是很了解这个,你试试看吧。
gongyan0910 2013-08-20
  • 打赏
  • 举报
回复
大家帮帮忙呀。很急.....

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧