Select command and test for number

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kevin

    #1

    Select command and test for number

    Hi All

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

    1. I have an OleDbDataadapte r, 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.FormatEx ception 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
  • Frank Oquendo

    #2
    Re: Select command and test for number

    Kevin wrote:[color=blue]
    > but if I pass a * then I get a System.FormatEx ception error.[/color]

    I don't think you can wildcard on a numeric field. Try passing in
    something like this:

    string.Format(" >= {0} AND <= {1}", int.MinValue, int.MaxValue);

    --
    There are 10 kinds of people. Those who understand binary and those who
    don't.


    (Pull the pin to reply)


    Comment

    Working...