以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  Select语句模糊查询出现问题,求老师指教  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=53050)

--  作者:雁过不留痕8
--  发布时间:2014/6/28 10:40:00
--  Select语句模糊查询出现问题,求老师指教
精确查询没有问题,
Tables("计划信息查询_Table1").Fill("Select * From {计划信息" & year1 & month1 & "} where" & "[计划号]=\'" & str1 & "\'","wmy1",True)
现要实现模糊查询,使用like语句
Tables("计划信息查询_Table1").Fill("Select * From {计划信息" & year1 & month1 & "} where" & "计划号 Like " & str1 ,"wmy1",True)
望老师帮忙


--  作者:Bin
--  发布时间:2014/6/28 10:43:00
--  
Tables("计划信息查询_Table1").Fill("Select * From {计划信息" & year1 & month1 & "} where" & "计划号 Like \'%" & str1 & "%\'","wmy1",True)
--  作者:雁过不留痕8
--  发布时间:2014/6/28 16:07:00
--  
老师帮忙看看这是我的源码,还是实现不了模糊查询,SELECT语句执行错误
Dim t1 As WinForm.TextBox = Forms("录入").Controls("TextBox1")
Dim str1 As String 
str1=t1.text
Dim d1 As Date = Date.Today
Dim year As Integer = d1.Year
Dim month As Integer = d1.Month
Dim year1 As String=CStr(year)


\'Tables("计划信息查询_Table1").Fill("Select * From {计划信息" & year1 & "} where" & "计划号 Like \'%" & str1 & "%\'","wmy1",True)

--  作者:雁过不留痕8
--  发布时间:2014/6/28 16:08:00
--  
准确查询的源码,可以
Dim t1 As WinForm.TextBox = Forms("录入").Controls("TextBox1")
Dim str1 As String 
str1=t1.text
\'str1= "\'*" & str1 & "*\'"
Dim d1 As Date = Date.Today
Dim year As Integer = d1.Year
Dim month As Integer = d1.Month
Dim year1 As String=CStr(year)

Tables("计划信息查询_Table1").Fill("Select * From {计划信息" & year1 & "} where" & "[计划号]=\'" & str1 & "\'","wmy1",True)

--  作者:Bin
--  发布时间:2014/6/28 16:10:00
--  
不可能的哦. 你弹出

messagebox.show("Select * From {计划信息" & year1 & "} where" & "计划号 Like \'%" & str1 & "%\'")   看看

--  作者:Bin
--  发布时间:2014/6/28 16:11:00
--  
Tables("计划信息查询_Table1").Fill("Select * From {计划信息" & year1 & "} where " & " 计划号 Like \'%" & str1 & "%\'","wmy1",True)

红色部分要有空格,不可以连在一起

--  作者:雁过不留痕8
--  发布时间:2014/6/28 16:17:00
--  
谢谢老师,是因为我没加空格的原因,
但是我还有一个问题,教程的3.8.5.1中的自定义录入界面之一的源码如下:
、将 TextBox1 的 TextChanged 事件代码设为:
Dim txt As String = e.Form.Controls("TextBox1").Text
Dim tbl As Table = Tables("窗口 1_Table1")
If txt = "" Then
狐表(FoxTable)帮助文件 广东省湛江市佳信科技有限公司荣誉作品
1320
tbl.Filter = ""
Else
txt = "\'*" & txt & "*\'"
tbl.Filter = "客户 ID Like " & txt & " Or 公司名称 Like " & txt & " Or 地址 Like
" & txt & " Or 联系人 Like " & txt
End If

--  作者:雁过不留痕8
--  发布时间:2014/6/28 16:18:00
--  
他的
tbl.Filter = "客户 ID Like " & txt & " Or 公司名称 Like " & txt & " Or 地址 Like
" & txt & " Or 联系人 Like " & txt
客户 ID LIke前面也没有空格哦

--  作者:雁过不留痕8
--  发布时间:2014/6/28 16:18:00
--  
* 和%在使用Like语句时有什么不同吗


--  作者:Bin
--  发布时间:2014/6/28 16:20:00
--  
统一用%吧