Results 1 to 6 of 6

Thread: Recordset query returns 'null' values.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2008
    Posts
    206

    Recordset query returns 'null' values.

    Hi there,

    I'm having some problems with my SQL queries. When I query a row in my Access database, the values are 'null' value. Sometimes it returns the contents of the row field, other times 'null'. I don't want null values.

    ------------------------------------------------------------------------

    partnercomparestring = "Select * From customers where customerid = " & Edit_Customers.Text24.Text & ""
    rs3.Open partnercomparestring, adoConnection, adOpenForwardOnly, adLockOptimistic

    If Edit_Customers.Text17.Text = rs3.Fields(15) Then 'partner title
    partnerredflag = partnerredflag + 1
    End If

    '--------------------------------------------------------------------

    In this case, rs3.fields(15) will return 'null' value. It should return "" if it has an empty value. My other queries run fine and I have tries adopting the same structure but to no avail.

    Thanks in advance

    Simon

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Recordset query returns 'null' values.

    You could append a nullstring to it like

    Code:
    If Edit_Customers.Text17.Text = (rs3.Fields(15) & vbNullString) Then 'partner title
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Recordset query returns 'null' values.

    If you do SELECT * (which no one will ever be able to convince me is ever necessary) you will get all fields in the record. If some of them are NULL, that is what will be returned.

    If you don't want NULL values, don't select the fields that have NULL values.

  4. #4
    Lively Member
    Join Date
    Jul 2007
    Posts
    74

    Re: Recordset query returns 'null' values.

    Hack is correct as * is the wild card for all queries where as if you want certain fileds enter it as "Select CustomerFName, CustomerLName, CustomerTeleNo" seperating them with a comma. Although VB returns empty strings as "", sql aint the same language and therefore return it as "null".

  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Recordset query returns 'null' values.

    Quote Originally Posted by mathy2007
    Although VB returns empty strings as "", sql aint the same language and therefore return it as "null".
    SQL returns null for null but returns an empty string if it is what is saved in the database.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  6. #6
    Lively Member
    Join Date
    Jul 2007
    Posts
    74

    Re: Recordset query returns 'null' values.

    what he didnt say!

    returns null for null and null if in database.

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