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. can any one tell me how to use the Trim() function in C# for any column in a table

can any one tell me how to use the Trim() function in C# for any column in a table

Scheduled Pinned Locked Moved ASP.NET
csharptutorial
6 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.
  • M Offline
    M Offline
    mavii
    wrote on last edited by
    #1

    string str = "SELECT cr_name, Trim(cr_pic), FROM criminal"; cr_pic contains image URL "E:\images\abc.jpg" i want to trim "E:\" Is this possible and what will be the way to do so

    S G S 4 Replies Last reply
    0
    • M mavii

      string str = "SELECT cr_name, Trim(cr_pic), FROM criminal"; cr_pic contains image URL "E:\images\abc.jpg" i want to trim "E:\" Is this possible and what will be the way to do so

      S Offline
      S Offline
      Sonia Gupta
      wrote on last edited by
      #2

      update the table (I mean use the sql query) Can u solve]

      Soniagupta1@yahoo.co.in

      M 1 Reply Last reply
      0
      • S Sonia Gupta

        update the table (I mean use the sql query) Can u solve]

        Soniagupta1@yahoo.co.in

        M Offline
        M Offline
        mavii
        wrote on last edited by
        #3

        i want to use the trip function in such scenerio SqlConnection conPubs; SqlCommand sc; SqlDataReader dr; conPubs = new SqlConnection("server=localhost;User ID=sa;Password=sasa;database=rescue15"); conPubs.Open(); string str = "SELECT cr_name, Trim(cr_pic), Trim(fing_print) FROM criminal ORDER BY cr_id DESC"; sc = new SqlCommand(str, conPubs); dr = sc.ExecuteReader(); GridView1.DataSource = dr; GridView1.DataBind(); but i thing i am not using correct sytax fot Trim() can u guide me in this scenario plz

        1 Reply Last reply
        0
        • M mavii

          string str = "SELECT cr_name, Trim(cr_pic), FROM criminal"; cr_pic contains image URL "E:\images\abc.jpg" i want to trim "E:\" Is this possible and what will be the way to do so

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          Try to write a short subject line for your post. Putting the entire question in the subject line makes it too long to be useful. You can't use C# functions in SQL. The Trim function is used to remove spaces at the beginning and end of a string. What you need is a function like Substring. Look in the documentation for the SQL syntax of the database you are using.

          --- single minded; short sighted; long gone;

          1 Reply Last reply
          0
          • M mavii

            string str = "SELECT cr_name, Trim(cr_pic), FROM criminal"; cr_pic contains image URL "E:\images\abc.jpg" i want to trim "E:\" Is this possible and what will be the way to do so

            S Offline
            S Offline
            saini arun
            wrote on last edited by
            #5

            you can use the following query... string str = "Select cr_name, substring(cr_pic,4,len(cr_pic)-4) from criminal"

            “The woods are lovely, dark and deep. But I have promises to keep, and miles to go before I sleep.”

            1 Reply Last reply
            0
            • M mavii

              string str = "SELECT cr_name, Trim(cr_pic), FROM criminal"; cr_pic contains image URL "E:\images\abc.jpg" i want to trim "E:\" Is this possible and what will be the way to do so

              S Offline
              S Offline
              saini arun
              wrote on last edited by
              #6

              you can use the following query... string str = "Select cr_name, substring(cr_pic,4,len(cr_pic)-4) from criminal"

              “The woods are lovely, dark and deep. But I have promises to keep, and miles to go before I sleep.”

              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