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. How to append DB values to a String

How to append DB values to a String

Scheduled Pinned Locked Moved ASP.NET
databasetutorial
4 Posts 4 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
    srinivaskonijeti
    wrote on last edited by
    #1

    Hi , I just want a piece of code for appending a single column data base values of a table in a single string seperating by "," or "|".

    M N A 3 Replies Last reply
    0
    • S srinivaskonijeti

      Hi , I just want a piece of code for appending a single column data base values of a table in a single string seperating by "," or "|".

      M Offline
      M Offline
      meeram395
      wrote on last edited by
      #2

      Could you explain a little bit more what exactly you want to do? Giving an example will be better

      Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.

      1 Reply Last reply
      0
      • S srinivaskonijeti

        Hi , I just want a piece of code for appending a single column data base values of a table in a single string seperating by "," or "|".

        N Offline
        N Offline
        Nouman Bhatti
        wrote on last edited by
        #3

        fetch your code in datareader from the table than loop throw the datareader and add the values in the string. steps to do that SqlConnection con = new SqlConnection("YOur connection string"); SqlCommand cmd = new SqlCommand(con,"Your query here"); con.Open(); DataReader dr = cmd.ExecuteNonQuery(); //confirm if this is the write function to call string strValues = string.Empty; while(dr.Read()) { strValues += dr[0].ToString(); } Note: There may be a bit of problem in this code.. i hope u can fix that.

        1 Reply Last reply
        0
        • S srinivaskonijeti

          Hi , I just want a piece of code for appending a single column data base values of a table in a single string seperating by "," or "|".

          A Offline
          A Offline
          AlexeiXX3
          wrote on last edited by
          #4

          Ask SQL question on SQl forum Declare @result varchar(8000) select @result = Coalesce (@results + ',', '') + columnName from tableName where condition

          Alexei Rodriguez

          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