Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. problem of saving multiline text into SQL table

problem of saving multiline text into SQL table

Scheduled Pinned Locked Moved ASP.NET
databasehelptutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Seraph_summer
    wrote on last edited by
    #1

    Hi, I need to save a multiline text into a SQL table. I use the fiedl type is Text. I found that the multiline mode is not maintained after saving into table, that is to say, all the text become only one line. thenn when this text is displayed in a view control such as datalist, then it is a very long text line, obviously, not good! how to treat this problem? thanks.

    A A 2 Replies Last reply
    0
    • S Seraph_summer

      Hi, I need to save a multiline text into a SQL table. I use the fiedl type is Text. I found that the multiline mode is not maintained after saving into table, that is to say, all the text become only one line. thenn when this text is displayed in a view control such as datalist, then it is a very long text line, obviously, not good! how to treat this problem? thanks.

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      Try to replace the string that your are showing on text box using BR like, string strAddress= strAddress.Replace("\r\n", "<BR>"); Hope this may helps you :)

      Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

      1 Reply Last reply
      0
      • S Seraph_summer

        Hi, I need to save a multiline text into a SQL table. I use the fiedl type is Text. I found that the multiline mode is not maintained after saving into table, that is to say, all the text become only one line. thenn when this text is displayed in a view control such as datalist, then it is a very long text line, obviously, not good! how to treat this problem? thanks.

        A Offline
        A Offline
        Abhishek Sur
        wrote on last edited by
        #3

        A simple newline puts character 13 on the input. So if you store it in the database it will hold only character 13(\n) In case you show in DataList, the formatting is done using HTML, so you need <br/> to have new line. Replace \n\r with <br/> and it will work.

        Abhishek Sur


        My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

        **Don't forget to click "Good Answer" if you like to.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups