Results 1 to 5 of 5

Thread: Big Problem

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2005
    Posts
    47

    Exclamation Big Problem

    I would be soooooo grateful if someone could give me an answer to this. I am taking data from Excel to VB.NET and validating it within the VB.NET program. Some of the data in the spreadsheet comes out as dbnull. I am currently converting the data to a string becuase of this but need to do some calculation on it so it needs to be in int format. Is there any way of converting a dbnull to some type of numerical integer?

    Thank you so much

    Julie

  2. #2
    Member
    Join Date
    Mar 2004
    Posts
    53

    Re: Big Problem

    I'd assume you are assigning the values taken from Excel to variables or integers, so I'd use a If... Then.. statement or somthing with the IsDBNull method. for example:

    VB Code:
    1. If IsDBNull(Whatever) then
    2. Whatever = "<This field is Null>"
    3. End If

    Thats best I can do without seeing some of your code or knowing exactly what you are doing. But if you need any more help feel free to email me at [email protected].

  3. #3
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Big Problem

    Well, it rather depends on how you are calculating things.

    VB Code:
    1. if whatever is dbnull.value then myValue = 0

    Might work or it might not depending on your formulae.

    Alternatively, using Single instead of integer will let you use Single.Nan in stead of the zero above. It won't be a numerical value but it will be a single.
    I don't live here any more.

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2005
    Posts
    47

    Re: Big Problem

    Thank you for your help.Because it is going straight into a database I would rather not program another if statement.

    at the moment this works dr("value").ToString
    BUT
    it doenst work for values with a minus and saying to int will not work on dbnull!!such a dilemma,are there any other datatypes which could possibly handle this?
    Last edited by jewly; Mar 4th, 2005 at 07:46 AM.

  5. #5
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Big Problem

    Quote Originally Posted by jewly
    Because it is going straight into a database I would rather not program another if statement.
    I'm having trouble understanding your situation. Can you post the chunk of code that you are having problems with (ie the whole subroutine).

    I see you have 2 further options:
    1. Write a class or a structure that can handle the problem and still be used in formulas.
    2. use an IF statement (why don't you like if statements?)
    I don't live here any more.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width