Need Help with select

D

Dave Brown

Hi all

I have a DataTable containing all String datatypes.
I need to query the table for records where one of the fields numeric value
is between two other numeric values.

I've been trying the following
string val1 = '1';
string val2 = '2';

filt = "Field1 between '"+val1+"' and '" + val2 + "'"

i dont understand how to differentiate between string and numeric values in
a select, so any help apprecitiated.

rgds,

Dave.
 
M

Miha Markic [MVP C#]

Hi Dave,

Try using
"Convert(Field1, 'System.Int32') >= " + val1 + " and Convert(Field1,
'System.Int32') <= " + val2;
 
D

Dave Brown

thanks ;)

Miha Markic said:
Hi Dave,

Try using
"Convert(Field1, 'System.Int32') >= " + val1 + " and Convert(Field1,
'System.Int32') <= " + val2;

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

Dave Brown said:
Hi all

I have a DataTable containing all String datatypes.
I need to query the table for records where one of the fields numeric value
is between two other numeric values.

I've been trying the following
string val1 = '1';
string val2 = '2';

filt = "Field1 between '"+val1+"' and '" + val2 + "'"

i dont understand how to differentiate between string and numeric values in
a select, so any help apprecitiated.

rgds,

Dave.
 

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

Top