Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2003
    Location
    Maryland
    Posts
    7

    Cool Unanswered: convert a Boolean to either String or Text?

    Hi,

    Does any one know how to convert a Boolean to either String or Text?
    I came across the ToText ( ) function but I can't seem to get it to work.
    According to the Crystal Reports For Visual Studio .NET ( Wrox book )
    the ToText ( ) the function should work to convert Booleans... but I have not IDEA HOW , since they don't provide any
    example! Can any one please shed some light? or maybe provide a better solution?

    thank you in advance.

    C.

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    What database are you talking about?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Dec 2003
    Location
    Maryland
    Posts
    7
    Originally posted by Brett Kaiser
    What database are you talking about?

    SQL Server. Did I post this question on the wrong Forum?

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    There is no ToText function in SQL server. That is a Crystal function. SQL Server does not even technically use "boolean" values. It uses the BIT value instead. It's possible that Crystal is misinterpreting the values it is receives from SQL server, because it is well-document that Crystal reports sucks big-time.

    blindman

  5. #5
    Join Date
    Dec 2003
    Location
    Maryland
    Posts
    7
    Originally posted by blindman
    There is no ToText function in SQL server. That is a Crystal function. SQL Server does not even technically use "boolean" values. It uses the BIT value instead. It's possible that Crystal is misinterpreting the values it is receives from SQL server, because it is well-document that Crystal reports sucks big-time.

    blindman
    I agree on the SUCK big time if we are talking about CR.NET. Version 8.5 seems to be pretty good to me. In any case, I guess I should have asked the question in terms of SQL Server since I want to create a VW and put it on the CR.NET as a DataSet. I have just realized that the way to convert a Boolean ( or Bit, thanks for the clarification) is as follows:

    select tbl.fieldname = (case tbl_name when boolean_value then 'yourString' end) from tblName

    Thank you,

    P.

  6. #6
    Join Date
    Dec 2002
    Posts
    1,245
    The only technical equivalent to what I think you're asking is:

    Code:
    CASE
      WHEN [MyColumn] = 0 THEN 'NO'
      WHEN [MyColumn] = 1 THEN 'YES'
      ELSE 'Null'
    END CASE
    That is assuming of course that the column is defined as:

    MyColumn BIT NULL

    The above CASE statement accepts that the field might be null. If that's not the case (the column allows no nulls), then you can just use two lines (omit the 'ELSE NULL').

    Other than that, blindman is right. There isn't a data type called 'boolean' in SQL Server and ToText is definitely not a standard SQL function.

    Good Luck,

    hmscott

  7. #7
    Join Date
    Dec 2002
    Posts
    1,245
    Sorry for the duplicate post; you beat me by a couple of minutes. tHet's kuz i suk at tping.

    hmscott

  8. #8
    Join Date
    Dec 2003
    Location
    Maryland
    Posts
    7
    Originally posted by hmscott
    Sorry for the duplicate post; you beat me by a couple of minutes. tHet's kuz i suk at tping.

    hmscott

    Your query also worked. Thank you hmscott. I'll see you arround.

Posting Permissions

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