Filtering Dataview [Strange Problem]

A

Anup Daware

Abstract: I want to filter a dataview with a value where column name
have a SPACE.
Description:-
I bind a dataview to a datagrid,
The query which is fetching the results in Dataset is something like
this:-
Select POSTAL_ADDRESS as "Postal Address" from Emp where ....
Now the column name in Dataview is "Postal Address" which is having a
space, with this column name when I am filtering the Dataview like:-
DataViewAddress.RowFilter = "Postal Address LIKE '*Bel1*'"
which throws following exception:-
System.Data.SyntaxErrorException: Syntax error: Missing operand after
'Address' operator.
I tried
DataViewAddress.RowFilter = "\"Postal Address\" LIKE '*Bel1*'"
I also tried the EncodedColumnName which replaces spaces with _x0020_
like:
DataViewAddress.RowFilter = "Postal_x0020_ Address LIKE '*Bel1*'" but
nothing worked and got the same exception every time..

I searched the net but I didnt get anything on it...
Any help will be Very-Much Helpful..
Thanks and Regards,
Anup Daware
 
A

Anup Daware

Got the Answer :)
It should be used as
DataViewAddress.RowFilter = "[Postal Address] LIKE '*Bel1*'"

It wasnt really that strange :)
 
G

Guest

And it only took you five minutes to work it out and then post back to the
newsgroup. Just goes to show that simply writing out your problem and
reading it back to yourself can be quite helpfull in jump starting your brain
;-)

Anup Daware said:
Got the Answer :)
It should be used as
DataViewAddress.RowFilter = "[Postal Address] LIKE '*Bel1*'"

It wasnt really that strange :)

Anup said:
Abstract: I want to filter a dataview with a value where column name
have a SPACE.
Description:-
I bind a dataview to a datagrid,
The query which is fetching the results in Dataset is something like
this:-
Select POSTAL_ADDRESS as "Postal Address" from Emp where ....
Now the column name in Dataview is "Postal Address" which is having a
space, with this column name when I am filtering the Dataview like:-
DataViewAddress.RowFilter = "Postal Address LIKE '*Bel1*'"
which throws following exception:-
System.Data.SyntaxErrorException: Syntax error: Missing operand after
'Address' operator.
I tried
DataViewAddress.RowFilter = "\"Postal Address\" LIKE '*Bel1*'"
I also tried the EncodedColumnName which replaces spaces with _x0020_
like:
DataViewAddress.RowFilter = "Postal_x0020_ Address LIKE '*Bel1*'" but
nothing worked and got the same exception every time..

I searched the net but I didnt get anything on it...
Any help will be Very-Much Helpful..
Thanks and Regards,
Anup Daware
 
D

Doug Goodman

Thanks for sharing as well - it helps others along the way!

dg


Anup Daware said:
Got the Answer :)
It should be used as
DataViewAddress.RowFilter = "[Postal Address] LIKE '*Bel1*'"

It wasnt really that strange :)

Anup said:
Abstract: I want to filter a dataview with a value where column name
have a SPACE.
Description:-
I bind a dataview to a datagrid,
The query which is fetching the results in Dataset is something like
this:-
Select POSTAL_ADDRESS as "Postal Address" from Emp where ....
Now the column name in Dataview is "Postal Address" which is having a
space, with this column name when I am filtering the Dataview like:-
DataViewAddress.RowFilter = "Postal Address LIKE '*Bel1*'"
which throws following exception:-
System.Data.SyntaxErrorException: Syntax error: Missing operand after
'Address' operator.
I tried
DataViewAddress.RowFilter = "\"Postal Address\" LIKE '*Bel1*'"
I also tried the EncodedColumnName which replaces spaces with _x0020_
like:
DataViewAddress.RowFilter = "Postal_x0020_ Address LIKE '*Bel1*'" but
nothing worked and got the same exception every time..

I searched the net but I didnt get anything on it...
Any help will be Very-Much Helpful..
Thanks and Regards,
Anup Daware
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top