Showing posts with label textbox. Show all posts
Showing posts with label textbox. 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.

Monday, March 19, 2012

How to Use RownNumber in a Matrix?

Hello Guys,

I am trying to count the number of rows that are displayed on my matrix report and display it in a textbox. What I use for the table reports doesn't really work:

="Number of records displayed: " + cstr(RowNumber("Data_Set_Name"))

This will return a number of rows returned by this data set. However, the count of rows that are actually being displayed in the matrix is very different. If anyone dealt with this before please let me know how to solve it. Thank you very much!

Try =CountRows(Fields!FieldName.Value) or =CountRows("DataSetName").

|||

I actually brought in another field, and did CountDistinct on it - now it works like a charm. Thank you so much for pointing me in the right direction.

Friday, March 9, 2012

How to use if else

Dear friends,

I have a webpage having a textbox and combobox. Combobox contains messers and country. If a user for instance enter?'India'?in?textbox?and?select?country?in?combobox.?I?want?to?retrieve?records?having?India?in?their?country?field.?
And?if?user?inputs?category?data in?textbox?and?select?category?from?combo?it?should?be?shown?that?category?records.?But?

It is giving error "Procedure or Function 'search' expects parameter '@.messers', which was not supplied."

ALTER PROCEDURE [dbo].[search]
@.messers nvarchar(70),
@.country nvarchar(20)

AS
IF @.country <> ''
BEGIN
select * from vendor where country like '%' +@.country+'%'
END
ELSE
IF @.messers <> ''
BEGIN
select * from vendor where messers like '%' +@.messers+'%'
END

Any help. PleaseYou need to set the default values for the parameters in the proc. Otherwise SQL Server expects you to send in BOTH parameters. Also I would add the condition @.param IS NOT NULL to make sure its not NULL. Checking for empty string is not sufficient.

ALTER PROCEDURE [dbo].[search]@.messersnvarchar(70)NULL,@.countrynvarchar(20)NULLASBEGINIF @.country <>''AND @.countryISNOT NULLBEGINselect *from vendorwhere countrylike'%' +@.country+'%'ENDELSEIF @.messers <>''AND @.messersISNOT NULLBEGINselect *from vendorwhere messerslike'%' +@.messers+'%'ENDEND