The DataTable has a column containing integers.
Filtering it as "Where ColName=12" filters fine.
Here is the problem. I want to filter the integer column using "Like". For a
string column the following will work "Where StrColName Like '12%'". I
need the same effect on the integer column.

Thanks for any pointers.

Re: This type of Filtering possible? by Marina

Marina
Thu Sep 30 13:23:50 CDT 2004

In you where clause, convert the integer to a string and then you can use
the LIKE clause. Valid function to use in the filter string are fully
documented in the .NET framework.

"Chris Botha" <chris_s_botha@AT.h.o.t.m.a.i.l.com> wrote in message
news:eVfAU8wpEHA.2900@TK2MSFTNGP12.phx.gbl...
> The DataTable has a column containing integers.
> Filtering it as "Where ColName=12" filters fine.
> Here is the problem. I want to filter the integer column using "Like". For
a
> string column the following will work "Where StrColName Like '12%'". I
> need the same effect on the integer column.
>
> Thanks for any pointers.
>
>



Re: This type of Filtering possible? by Miha

Miha
Thu Sep 30 13:40:26 CDT 2004

Yes, use CONVERT expression keyword (see DataColumn.Expression .net help)

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Chris Botha" <chris_s_botha@AT.h.o.t.m.a.i.l.com> wrote in message
news:eVfAU8wpEHA.2900@TK2MSFTNGP12.phx.gbl...
> The DataTable has a column containing integers.
> Filtering it as "Where ColName=12" filters fine.
> Here is the problem. I want to filter the integer column using "Like". For
> a
> string column the following will work "Where StrColName Like '12%'". I
> need the same effect on the integer column.
>
> Thanks for any pointers.
>
>



Re: This type of Filtering possible? by Chris

Chris
Thu Sep 30 13:45:31 CDT 2004

My mistake, I should not have used "Where" in my examples for the RowFilter
string, suggesting a select statement, in which case I can use the CAST or
CONVERT functions.

In my case the data is selected into the DataTable already and I can't
change the select statement (don't have a lot of control over that part
unfortunately). So the table contains an integer column and the requirement
is to filter on the first number of digits entered.
The best that I can come up with at the moment is to loop through the table
and compare the column of each row (after converting it to a string) to the
digits. This happens as the user is entering digits, which is a bit slow if
there are many rows. Changing the RowFilter of the DataView for a string
field on the fly as the user types (using LIKE), is blinding fast.

"Marina" <someone@nospam.com> wrote in message
news:OMvwjqxpEHA.3640@tk2msftngp13.phx.gbl...
> In you where clause, convert the integer to a string and then you can use
> the LIKE clause. Valid function to use in the filter string are fully
> documented in the .NET framework.
>
> "Chris Botha" <chris_s_botha@AT.h.o.t.m.a.i.l.com> wrote in message
> news:eVfAU8wpEHA.2900@TK2MSFTNGP12.phx.gbl...
> > The DataTable has a column containing integers.
> > Filtering it as "Where ColName=12" filters fine.
> > Here is the problem. I want to filter the integer column using "Like".
For
> a
> > string column the following will work "Where StrColName Like '12%'". I
> > need the same effect on the integer column.
> >
> > Thanks for any pointers.
> >
> >
>
>



Re: This type of Filtering possible? by Marina

Marina
Thu Sep 30 13:52:49 CDT 2004

You did not carefully read my response.

I was suggesting using the conversion function in the filter clause.

"Chris Botha" <chris_s_botha@AT.h.o.t.m.a.i.l.com> wrote in message
news:%23pmav4xpEHA.1300@TK2MSFTNGP12.phx.gbl...
> My mistake, I should not have used "Where" in my examples for the
RowFilter
> string, suggesting a select statement, in which case I can use the CAST or
> CONVERT functions.
>
> In my case the data is selected into the DataTable already and I can't
> change the select statement (don't have a lot of control over that part
> unfortunately). So the table contains an integer column and the
requirement
> is to filter on the first number of digits entered.
> The best that I can come up with at the moment is to loop through the
table
> and compare the column of each row (after converting it to a string) to
the
> digits. This happens as the user is entering digits, which is a bit slow
if
> there are many rows. Changing the RowFilter of the DataView for a string
> field on the fly as the user types (using LIKE), is blinding fast.
>
> "Marina" <someone@nospam.com> wrote in message
> news:OMvwjqxpEHA.3640@tk2msftngp13.phx.gbl...
> > In you where clause, convert the integer to a string and then you can
use
> > the LIKE clause. Valid function to use in the filter string are fully
> > documented in the .NET framework.
> >
> > "Chris Botha" <chris_s_botha@AT.h.o.t.m.a.i.l.com> wrote in message
> > news:eVfAU8wpEHA.2900@TK2MSFTNGP12.phx.gbl...
> > > The DataTable has a column containing integers.
> > > Filtering it as "Where ColName=12" filters fine.
> > > Here is the problem. I want to filter the integer column using "Like".
> For
> > a
> > > string column the following will work "Where StrColName Like '12%'".
I
> > > need the same effect on the integer column.
> > >
> > > Thanks for any pointers.
> > >
> > >
> >
> >
>
>



Re: This type of Filtering possible? by Beverley

Beverley
Thu Sep 30 14:10:26 CDT 2004

If it's an integer, could you not just do something like "between 120000 and 129999" or
">= 120000 and < 130000" to get all of the ones that begin with 12?

Of course, this method won't work if you really want to see 12, 120-129, 1200-1299, etc

Beverley

> > "Chris Botha" <chris_s_botha@AT.h.o.t.m.a.i.l.com> wrote in message
> > news:eVfAU8wpEHA.2900@TK2MSFTNGP12.phx.gbl...
> > > The DataTable has a column containing integers.
> > > Filtering it as "Where ColName=12" filters fine.
> > > Here is the problem. I want to filter the integer column using "Like".
> For
> > a
> > > string column the following will work "Where StrColName Like '12%'". I
> > > need the same effect on the integer column.
> > >
> > > Thanks for any pointers.
> > >
> > >
> >
> >
>
>



Re: This type of Filtering possible? by Chris

Chris
Thu Sep 30 14:08:13 CDT 2004

Right, thanks, exactly what I was looking for.

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:u#$x0zxpEHA.3980@TK2MSFTNGP12.phx.gbl...
> Yes, use CONVERT expression keyword (see DataColumn.Expression .net help)
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & development
> miha at rthand com
> www.rthand.com
>
> "Chris Botha" <chris_s_botha@AT.h.o.t.m.a.i.l.com> wrote in message
> news:eVfAU8wpEHA.2900@TK2MSFTNGP12.phx.gbl...
> > The DataTable has a column containing integers.
> > Filtering it as "Where ColName=12" filters fine.
> > Here is the problem. I want to filter the integer column using "Like".
For
> > a
> > string column the following will work "Where StrColName Like '12%'". I
> > need the same effect on the integer column.
> >
> > Thanks for any pointers.
> >
> >
>
>



Re: This type of Filtering possible? by Chris

Chris
Thu Sep 30 14:12:24 CDT 2004

Thanks, it is working with the Convert now.

"Marina" <someone@nospam.com> wrote in message
news:#G5Jw6xpEHA.2696@TK2MSFTNGP15.phx.gbl...
> You did not carefully read my response.
>
> I was suggesting using the conversion function in the filter clause.
>
> "Chris Botha" <chris_s_botha@AT.h.o.t.m.a.i.l.com> wrote in message
> news:%23pmav4xpEHA.1300@TK2MSFTNGP12.phx.gbl...
> > My mistake, I should not have used "Where" in my examples for the
> RowFilter
> > string, suggesting a select statement, in which case I can use the CAST
or
> > CONVERT functions.
> >
> > In my case the data is selected into the DataTable already and I can't
> > change the select statement (don't have a lot of control over that part
> > unfortunately). So the table contains an integer column and the
> requirement
> > is to filter on the first number of digits entered.
> > The best that I can come up with at the moment is to loop through the
> table
> > and compare the column of each row (after converting it to a string) to
> the
> > digits. This happens as the user is entering digits, which is a bit slow
> if
> > there are many rows. Changing the RowFilter of the DataView for a string
> > field on the fly as the user types (using LIKE), is blinding fast.
> >
> > "Marina" <someone@nospam.com> wrote in message
> > news:OMvwjqxpEHA.3640@tk2msftngp13.phx.gbl...
> > > In you where clause, convert the integer to a string and then you can
> use
> > > the LIKE clause. Valid function to use in the filter string are fully
> > > documented in the .NET framework.
> > >
> > > "Chris Botha" <chris_s_botha@AT.h.o.t.m.a.i.l.com> wrote in message
> > > news:eVfAU8wpEHA.2900@TK2MSFTNGP12.phx.gbl...
> > > > The DataTable has a column containing integers.
> > > > Filtering it as "Where ColName=12" filters fine.
> > > > Here is the problem. I want to filter the integer column using
"Like".
> > For
> > > a
> > > > string column the following will work "Where StrColName Like '12%'".
> I
> > > > need the same effect on the integer column.
> > > >
> > > > Thanks for any pointers.
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Re: This type of Filtering possible? by Chris

Chris
Thu Sep 30 14:21:05 CDT 2004

Hi Beverly,

I was a bit knocked over in the beginning until I read the help on the
DataColumn.Expression (thanks to Miha and Marina) and it works, pretty
powerful. For an integer column called IntCol an example would be
TheView.RowFilter = "CONVERT(IntCol, 'System.String') Like '" & theText &
"%'"
"Beverley" <ali_webitems@hotmail.com> wrote in message
news:eyC#lEypEHA.132@TK2MSFTNGP14.phx.gbl...

> If it's an integer, could you not just do something like "between 120000
and 129999" or
> ">= 120000 and < 130000" to get all of the ones that begin with 12?
>
> Of course, this method won't work if you really want to see 12, 120-129,
1200-1299, etc
>
> Beverley
>
> > > "Chris Botha" <chris_s_botha@AT.h.o.t.m.a.i.l.com> wrote in message
> > > news:eVfAU8wpEHA.2900@TK2MSFTNGP12.phx.gbl...
> > > > The DataTable has a column containing integers.
> > > > Filtering it as "Where ColName=12" filters fine.
> > > > Here is the problem. I want to filter the integer column using
"Like".
> > For
> > > a
> > > > string column the following will work "Where StrColName Like '12%'".
I
> > > > need the same effect on the integer column.
> > > >
> > > > Thanks for any pointers.
> > > >
> > > >
> > >
> > >
> >
> >
>
>