Search code examples
c#sqlcrystal-reports

Individual Character Boxing Crystal Reports


I am pulling a string from a database (SQL) and it is being put into a Crystal Report, C# is handling the connection strings.

I need get each character of the string (between 6 and 16) in it's own box. Similar to those of Direct Debit forms where they show Sort Codes.

Is this possible through Crystal Reports creator, using Visual Studio 2013?

If not through a function or option within Crystal Reports designer, then how would be best?


Solution

  • Unfortunately as far as I'm aware crystal won't deal with separate character boxing.

    I have the following that I use for something similar, it's a little untidy but effective

    declare @string varchar(16)
    set @string = 'abcdefghijklmnop'
    
    SELECT
    LEFT(@string,1),
    RIGHT(LEFT(@string,2),1),
    RIGHT(LEFT(@string,3),1),
    RIGHT(LEFT(@string,4),1),
    RIGHT(LEFT(@string,5),1),
    RIGHT(LEFT(@string,6),1),
    RIGHT(LEFT(@string,7),1),
    RIGHT(LEFT(@string,8),1),
    RIGHT(LEFT(@string,9),1),
    RIGHT(LEFT(@string,10),1),
    RIGHT(LEFT(@string,11),1),
    RIGHT(LEFT(@string,12),1),
    RIGHT(LEFT(@string,13),1),
    RIGHT(LEFT(@string,14),1),
    RIGHT(LEFT(@string,15),1)
    

    Of course all you need to do is replace @string with your data and add in some alias's so you can make sense of it in crystal

    SQL Fiddle http://sqlfiddle.com/#!6/9eecb7/396