Select command and test for number

  • Thread starter Thread starter Kevin
  • Start date Start date
K

Kevin

Hi All

I have two questions, if someone can help me or point me
in the right direction.

1. I have an OleDbDataadapter, OledbConnection and
DataSet. Now the select command for my DataAdapter has a
select command like the following : SELECT fields FROM
table WHERE certainfield = aVariable

I pass a variable into a function to satisfy the Where
statement, btw the data type of the field in the WHERE
statement is a long. When I pass a valid number like
340995, the select command works fine and I am able to
populate the DataSet, but if I pass a * then I get a
System.FormatException error. Bsically I would like this
select command to cater for a specific number, or all
numbers, is there a way to keep the same SQL SELECT
statement and just pass the specific number or the *?

2. How to I test if a string, not Char, is numeric or not?

TIA for any help
Much aprreciated
Kevin
 
1: if( aVariable != "*" ) SelectCommand += " WHERE certainfield = "
+ aVariable;

2: Well you can try to Int32.Parse(string); and catch any errors.
 
Back
Top