Friday, March 16, 2012

Parameter query - spaces in query

Hi:

I am trying to build maste/detail page.

1. I have on my page drop down control based on sqldata sources with the concataned fields as follows:

SELECT DISTINCT LastName + ' ' + FirstName AS Expr1 FROM dbo.Table1

It displays First Name space and Last name in the box and works fine.

2. I placed on my form a grIdview

In data source I am trying to use parameter filter in SQL select query and the same query as for drop down as follows:

SELECT LastName + ' ' + SiteFirstName AS Expr1, field1, field2, etc......
FROM dbo.Table1
WHERE (LastName + ' ' + FirstName = @dotnet.itags.org.filtername)

This query when run without filter shows LastName and SPACES (I believe 25 - field length?) and FirstName. It should be only one space so it could match the search from my first query.

So when I type values it will not find the record because of the spaces. Can you help!!

u just try this,

select * from (SELECT LastName + ' ' + SiteFirstName AS Expr1, field1, field2, etc......
FROM dbo.Table1) as e where Expr1 = @.filtername

Thanks so much for your help, I worked with this and then I used trim function and got read of spaces.

0 comments:

Post a Comment