none
Select Query returns a string of length 12 with empty space RRS feed

  • Question

  • Hi There:

    I have a table which has a column of nchar(12). When I am making a Select query in VB.NEt, its always returning either a 12 length empty string(when ther is no data in this column row) or a value string of 12 length(when there is a value). My question is how can I check if this has a value or not. I tried IS NULL, string.NUllOrEmpty(), string.empty etc nothing is working.

    Thanks

    • Moved by Bob Beauchemin Tuesday, March 26, 2013 7:03 PM Moved to forum for .NET client-side SqlClient for best response
    Tuesday, March 26, 2013 12:35 PM

Answers

  • IsNullOrWhiteSpace is VS2010 + while IsNullOrEmpty is VS2008

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    • Marked as answer by syedripon Tuesday, April 2, 2013 5:13 PM
    Saturday, March 30, 2013 11:11 AM
  • Thansk to all. TRim(string) worked for me perfectly. This is what I was looking for. Thanks.
    • Marked as answer by syedripon Tuesday, April 2, 2013 5:13 PM
    Tuesday, April 2, 2013 5:13 PM

All replies

  • Hi  Syedripon,

    Welcome to the MSDN forum.

    Did you try this?

    String.IsNullOrWhiteSpace(stringYouWantToCompare)

    Good day.


    Alexander Sun [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Wednesday, March 27, 2013 8:05 AM
  • Hi Alex:

    String.IsNullOrWhiteSpace() is not showing up in vs2008. I dont see this function.

    Thanks 

    Thursday, March 28, 2013 4:39 PM
  • If your database supports CASE try something like what is shown below

    SELECT 
       CompanyName, 
       CASE When Trim(Web_Site_Address_Text) = '' Then
          '(none)'
       ELSE
          Trim(Web_Site_Address_Text)
       END As WebSite
    FROM Companies
    Or use Trim simply in the WHERE condition to rule out this issue. I have seen this in IBM-DB2 were data was obtained from a main frame, where the main frame always sends max length of a field length (not seen often but it does pop-up now and then)

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Saturday, March 30, 2013 11:09 AM
  • IsNullOrWhiteSpace is VS2010 + while IsNullOrEmpty is VS2008

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    • Marked as answer by syedripon Tuesday, April 2, 2013 5:13 PM
    Saturday, March 30, 2013 11:11 AM
  • Thansk to all. TRim(string) worked for me perfectly. This is what I was looking for. Thanks.
    • Marked as answer by syedripon Tuesday, April 2, 2013 5:13 PM
    Tuesday, April 2, 2013 5:13 PM