Select and format a text in a varchar column including char(13) and char(10)

  • One purchased app stored user's multiple lines input into a varchar column in which including char(13) and char(10).

    My app need to select this value and format to multiple lines text in one text box.

    How to code to output it?

  • your application would handle the CrLf automatically, with zero changes, as long as you are using the right object;

    in C#.Net Windows Application,in a windows app, you'd could use System.Windows.Forms.Label,System.Windows.Forms.TextBox with the Property Multiline = True, or a System.Windows.Forms.RichTextBox;

    in a web application, you have to use a <Textarea> object, and not an <input type="text"

    WPF is the same idea, but i don't remember the object off the top of my head.

    what is your target applicaiton's platform?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • For example, user may input text like below.

    Welcome to Order application

    Your registration is completed

    Using code to store above text into SQL column is

    'Welcome to Order application' + char(13) + char(10) +'Your registration is completed'

    But, if you open this column, you will see as below

    Welcome to Order application Your registration is completed

    How to code to read text and display like

    Welcome to Order application

    Your registration is completed

  • I am working with ASP.NET

  • Thank you for your point.

    Once I change text box form single line to multiple lines mode, it works great without one code.

  • Your app (on the frontend) needs to replace the CHAR(10) and CHAR(13) characters from the stored value to the linefeeds used by this app. Most applications handle this stuff automatically correct. If you execute the sample below in SSMS in GRID mode, you'll see the results (from the SLECT) in a single line cel but on the message tab you see the results (from the PRINT) as multiple lines. If you execute this sample in TEXT mode, you see both results as multiple lines.

    set nocount on

    declare @line nvarchar(50)

    set @line = 'line 1' + CHAR(10) + CHAR(13) + 'line 2'

    select @line

    print @line

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply