Results 1 to 6 of 6

Thread: Need help checking null values in text type fileds in Visual Basic 5

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2004
    Posts
    3

    Need help checking null values in text type fileds in Visual Basic 5

    Hi

    I am working on a project in Visual Basic 5 and SQL Server 7 as database where I need to insert and update data in text type fields.

    The problem I am facing is that whenever I check for null values in text type fields I am getting an error trying to insert or update.

    Is there a way to check for null values in text fields and bypass it if its true.

    Any help would be highly appreciated.

    Thanks in advance.

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    isnull function

    add & "" to make it a blank string

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2004
    Posts
    3

    Need help checking null values in text type fileds in Visual Basic 5

    Hi

    Thanks for your reply but my problem is that using IsNull function, when I check the text fields, it returns null values even if the text field contains valid data.

    Also when I am updating text fields in the database I am getting errors.

    Is there a way around.

    Thanks

  4. #4
    Hyperactive Member dRAMmer's Avatar
    Join Date
    Oct 2001
    Location
    strangelans
    Posts
    463
    Thanks for your reply but my problem is that using IsNull function, when I check the text fields, it returns null values even if the text field contains valid data.
    if you are testing for null values in SQL, do it like:
    Code:
    IF YourFld IS NULL 
    --do your stuff here
    ELSE
    --YourFld has a value
    Also when I am updating text fields in the database I am getting errors.
    What exactly is the error?
    live, code and die...

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2004
    Posts
    3

    Need help checking null values in text type fileds in Visual Basic 5

    Hi

    I get the error invalid use of null. Actually I have got the work around which is to use a temporary variable which I can then check for null instead of check directly the recordset field.

    Anyways thanks guys to everybody who responded.

    Bye

  6. #6
    Hyperactive Member dRAMmer's Avatar
    Join Date
    Oct 2001
    Location
    strangelans
    Posts
    463

    Re: Need help checking null values in text type fileds in Visual Basic 5

    Originally posted by Jeev
    Hi

    I get the error invalid use of null. Actually I have got the work around which is to use a temporary variable which I can then check for null instead of check directly the recordset field.

    Anyways thanks guys to everybody who responded.

    Bye
    No need to use a variable.

    To get values from a field in your RS object which may contain NULL use:
    Code:
    rs.Fields("Fld_x").Value & ""
    if not, you will get the error invalid use of null

    To check if the field is null
    Code:
    IsNull(rs.Fields("Fld_x").Value)
    Also it's always best if you will post the code you're having problem with
    live, code and die...

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