我是用VB+Access做的系统,在做模糊查询功能时,我发现只要我在查询条件中输入了"'"就会出错,如:content like '%'12345%',但是content like '%12345%'我在查询时是正确的。(这是Sql语句的一小段)我以前做过Sql Server的系统,知道在Sql Server中象content like '%'12345%'这样用是没错的。
...全文
3110打赏收藏
模糊查询,遇到问题。
我是用VB+Access做的系统,在做模糊查询功能时,我发现只要我在查询条件中输入了"'"就会出错,如:content like '%'12345%',但是content like '%12345%'我在查询时是正确的。(这是Sql语句的一小段)我以前做过Sql Server的系统,知道在Sql Server中象content like '%'12345%'这样用是没错的。
这是你在录入时遇到的问题,我给你一个函数,你可以限制他录入其他字符,只能录入数字!
Function sffunLimitNumber(ByVal IntVal As Integer) As Integer
If (IntVal <> vbKeyDelete) _
And (IntVal <> vbKeyBack) _
And (IntVal <> 13) _
And (IntVal < 48 Or IntVal > 57) Then
IntVal = 0
End If
sffunLimitNumber = IntVal
End Function
在text1的keypress事件中写
Private Sub text1_KeyPress(KeyAscii As Integer)
KeyAscii = sffunLimitNumber(KeyAscii)
End Sub