In my TableAdapter I have a SQL Query like below:
SELECT * FROM Vehicles WHERE (VehicleID LIKE @branchList)
The Variable i pass to @branchList
is a simple join on a few CHARS like ABC
The problem i have is i need to enclose ABC
in Brackets as a need the first character to match any char in the charlist supplied, so i combine the charlist to look like [ABC]%
.
below is my VB.NET code to do this and attempt to populate the datagridview:
Try
Dim br As String = ""
For Each branch In MenuForm.Branches
br = br & branch
Next
br = "[" & br & "]%"
Me.VehiclesTableAdapter.FillByBranchList(Me.VehiclesDataSet.Vehicles, br)
Catch ex As Exception
MsgBox(ex.Message)
End Try
but this yields no results, but when i copy the query to a SQL Server Editor and declare @branchList
like this:
DECLARE @branchList as NVARCHAR(MAX) = '[ABC]%'
I get the rows I was expecting.
Am I missing something or is this an issue/limitation with tableadapters?