Showing posts with label wildcard. Show all posts
Showing posts with label wildcard. Show all posts

Wednesday, March 28, 2012

How to use wildcard characters with control parameters

Hi guys,

I have a gridview and textbox. I can filter the grid just fine with the textbox, but I would like to allow the user to type in part of a name.

I thought something like this would work but it doesn't:

Emp_Name LIKE'%'+@.Emp_Name+'%'

Thank you.

That should work|||

That's what I thought too, but it doesn't. I guess I should give more info.

I am using an objectdatasource to populate the gridview. The object is a table adapter. It seems like the wildcards are completely ignored. If I am looking for smith, I can type smith and get the correct results. But if I type smit, nothing gets returned, though I want Smith to be returned. If I actually literally type the wildcard characters into the textbox the results are very unpredictable. Typing %smit% will return the correct result, as will %smi% But if I type %sm% then nothing gets returned. It seems as though the number of characters matter when doing this. And like I said, if I have'%'+@.Emp_Name+'%' in the actual query within the table adapter, the wildcards are ignored. Hopefully there is some kind of solution to this.

Thank you very much.

|||Anyone? Let me know if you need more information.

Friday, February 24, 2012

How to use a Wildcard with the value for the parameter?

I have a report that selects certain records based on what the user enters for the parameter but I'm trying to allow the user to enter a wildcard and show the relevant records. I used like and had the user add an * or even a % but it still returns nothing. Records are returned only when the user enters the full value with no wildcards. Help.

SELECT DISTINCT
PDFBM.ASSEMBLY_ID, PDFBM.COMPONENT_ID, PDFBM.REQUIRED_QTY, ICFPM.PART_DESC, ICFPM.DWG_REV, ICFPM.PENDING_ECN,
dbo.ICFSS.STORES_CODE, dbo.ICFSS.STOCK_LOCATION
FROM dbo.ICFPM ICFPM INNER JOIN
dbo.PDFBM PDFBM ON ICFPM.PART_ID = PDFBM.ASSEMBLY_ID INNER JOIN
dbo.ICFSS ON ICFPM.PART_ID = dbo.ICFSS.PART_ID
WHERE (PDFBM.COMPONENT_ID LIKE @.componentid) AND (PDFBM.ASSEMBLY_ID LIKE '350%')
ORDER BY PDFBM.ASSEMBLY_ID, PDFBM.COMPONENT_ID

A

I'm not sure but try converting the query to a dynamic query:

="SELECT DISTINCT
PDFBM.ASSEMBLY_ID, PDFBM.COMPONENT_ID, PDFBM.REQUIRED_QTY, ICFPM.PART_DESC, ICFPM.DWG_REV, ICFPM.PENDING_ECN,
dbo.ICFSS.STORES_CODE, dbo.ICFSS.STOCK_LOCATION
FROM dbo.ICFPM ICFPM INNER JOIN
dbo.PDFBM PDFBM ON ICFPM.PART_ID = PDFBM.ASSEMBLY_ID INNER JOIN
dbo.ICFSS ON ICFPM.PART_ID = dbo.ICFSS.PART_ID
WHERE (PDFBM.COMPONENT_ID LIKE '" + Parameters!componentid.Value + "') AND (PDFBM.ASSEMBLY_ID LIKE '350%')
ORDER BY PDFBM.ASSEMBLY_ID, PDFBM.COMPONENT_ID"

Regards,

Telmo Moreira

|||

try:

LIKE @.parameter + '%')

drop the user adding the wildcard char