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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Data from textbox into database and newlines

Data from textbox into database and newlines

Scheduled Pinned Locked Moved C#
databasequestionannouncement
3 Posts 2 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.
  • G Offline
    G Offline
    Genbox
    wrote on last edited by
    #1

    Hi. I have a very simple news system, that takes some text from a multiline textbox and insert it into a access database. But when i save the data to the database, the newlines dont get saved with the data. How do i save the newlines with the data to the database, and then display it on my site. here is the code i use to insert into the database, it's just a sqldatasource. news.InsertCommand = "INSERT INTO [news] ([headline], [content], [date], [user]) VALUES ('"+ txtHeadline.Text +"','"+txtContent.Text+ "','"+DateTime.Now.ToString()+"','"+User.Identity.Name.ToString()+"')"; news.Insert();

    G A 2 Replies Last reply
    0
    • G Genbox

      Hi. I have a very simple news system, that takes some text from a multiline textbox and insert it into a access database. But when i save the data to the database, the newlines dont get saved with the data. How do i save the newlines with the data to the database, and then display it on my site. here is the code i use to insert into the database, it's just a sqldatasource. news.InsertCommand = "INSERT INTO [news] ([headline], [content], [date], [user]) VALUES ('"+ txtHeadline.Text +"','"+txtContent.Text+ "','"+DateTime.Now.ToString()+"','"+User.Identity.Name.ToString()+"')"; news.Insert();

      G Offline
      G Offline
      Genbox
      wrote on last edited by
      #2

      Hi. To get newlines in the displayet data on the site, I just replaced "newline" with
      like this: txtContent.Text.Replace(Environment.NewLine, "
      ") -- modified at 6:35 Wednesday 29th March, 2006

      1 Reply Last reply
      0
      • G Genbox

        Hi. I have a very simple news system, that takes some text from a multiline textbox and insert it into a access database. But when i save the data to the database, the newlines dont get saved with the data. How do i save the newlines with the data to the database, and then display it on my site. here is the code i use to insert into the database, it's just a sqldatasource. news.InsertCommand = "INSERT INTO [news] ([headline], [content], [date], [user]) VALUES ('"+ txtHeadline.Text +"','"+txtContent.Text+ "','"+DateTime.Now.ToString()+"','"+User.Identity.Name.ToString()+"')"; news.Insert();

        A Offline
        A Offline
        albCode
        wrote on last edited by
        #3

        In which column you have to save data with new lines? _____________________ Proud to be Albanian _____________________

        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