带参数的access模糊查询怎么写啊?
Public Function GetProduct_Info(ByVal Name As String) As DataTable
conn.Open()
Access = "Select ID, ClassName, Name, AddTime, IsShow FROM Product where Name = @Name "
Adcmd = New OleDbDataAdapter(Access, conn)
Adcmd.SelectCommand.Parameters.Add( "@Name ", OleDbType.Char).Value = Name
Dim dt As New DataTable
Adcmd.Fill(dt)
conn.Close()
Return dt
End Function
怎么把where Name = @Name "改成模糊查询?
------解决方案--------------------Access = "SELECT ID, ClassName, Name, AddTime, IsShow FROM Product WHERE Name LIKE @Name "
------解决方案--------------------Access = "SELECT ID, ClassName, Name, AddTime, IsShow FROM Product WHERE Name LIKE '% ' + @Name + '% '
或者
Access = "SELECT ID, ClassName, Name, AddTime, IsShow FROM Product WHERE Name LIKE '% ' + ? + '% '
没装Access ,试试
我怎么记得Access的参数化查询是?,不是SQL 里面的@ + 参数名
------解决方案--------------------like '% '+@Name+ '% ' "