CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 1999
    Posts
    3

    How to handle empty fields in database....



    Hi,


    I'm using Recordset to retrieve data records from the database and place

    them in a ListView.


    The problem I'm facing now is that some of the fields in the recordset is

    empty. When I tried to run my application, it just stop at the record which

    has an empty field and returns "Invalid use of Null'.


    I would like to know what I should do for the recordset to retrieve empty

    fields from the database.


    Thanks in advance


    Angus Ching




  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: How to handle empty fields in database....



    Hi


    This is covered in the Open FAQ in the CodeGuru/vb site - to fix your problem, simply append an empty string (ie. "") to the assignment,


    e.g.


    Text1.Text = oRecordSet.Fields("TestField") & ""


    That way, any null value is converted to an empty string.


    Look at then Open FAQ for more help

    http://www.codeguru.com/vb/openfaq/open_faq.shtml


    Regards


    Chris Eastwood



  3. #3
    Join Date
    May 1999
    Posts
    7

    Re: How to handle empty fields in database....



    Hello Angus,


    the other way as that of Chris is that you check in your program, if a field is empty, with the function isnull.


    if not isnull(Recordset!Field) then ... else ...


    Greetings

    Ting

  4. #4
    Guest

    Re: How to handle empty fields in database....

    You could probably check with the ISnull Function when you are retriveing from the databse , branch off when it is Null


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

Featured