Reputation: 39
The code below works great, and I need it to do more :). It is for vb.net 2008 with access database.
At the moment it matches based on paramValue, and needs an exact match.
How can I change it to look for a pattern instead?? For example I want anything that contains the text "Fizz" and then "Bom".
--And PLEASE share any link where I can learn about this blend of SQL+access+vb.net.
Thank you! Steve
Dim table As New DataTable(tableName)
table.Locale = System.Globalization.CultureInfo.InvariantCulture
Using connection As New OdbcConnection(ConnectionString)
connection.Open()
Dim query As String = String.Format("SELECT * FROM [{0}] WHERE [{1}] = ?", _
tableName, _
paramName)
Dim selectCommand As New OdbcCommand(query, connection)
selectCommand.Parameters.Add(New OdbcParameter("@" & paramName, paramValue))
Dim adapter As New OdbcDataAdapter(selectCommand)
adapter.FillSchema(table, SchemaType.Mapped)
adapter.Fill(table)
End Using
Return table
Upvotes: 1
Views: 714
Reputation: 3746
Reference link : HERE
Dim SelectQry = "SELECT * FROM [{0}] WHERE [{1}] like '%" & _
strYourSearchValue & " %'"
Upvotes: 1
Reputation: 19598
You can use a LIKE operator to do that.
SELECT * FROM TableName WHERE Name LIKE '%Fizz%' AND Name LIKE '%Bom%'
Upvotes: 0