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. General Programming
  3. C#
  4. Trim Column value access Interbase

Trim Column value access Interbase

Scheduled Pinned Locked Moved C#
databasequestioncsshelp
7 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.
  • P Offline
    P Offline
    P T R K
    wrote on last edited by
    #1

    Hi, I have a project which is used the interbase database. Issue is, one column with datatype char(100) in a table. I will bind this column in grid when empty space also binded. I have used to ltrim(rtrim(Name)) function in SQL statment. It wouldnt affect. How can i trim this empty space? Thanks in advance.

    L 1 Reply Last reply
    0
    • P P T R K

      Hi, I have a project which is used the interbase database. Issue is, one column with datatype char(100) in a table. I will bind this column in grid when empty space also binded. I have used to ltrim(rtrim(Name)) function in SQL statment. It wouldnt affect. How can i trim this empty space? Thanks in advance.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Strange the SQL TRIM would not work How ever , I will give you another solution , with code :

      MyDataTable = New DataTable ();
      SqlConnect con = new SqlConnection ("connection string goes here ") ;
      SqlDataAdapter SqlDa = new SqlDataAdapter ("SELECT * FROM myTable", conn);
      SqlDa.Fill(myDataTable);

      foreach ( DataRow dr in MyDataTable.Rows)
      {
      dr["ColumnName"] = dr["ColumnName"].toString().Trim();
      }

      Hope This Help , ------------ :rose: Please Increase the hit's of my website by 1 ::rose: ----------- www.smart-arab.com

      I know nothing , I know nothing ...

      P 1 Reply Last reply
      0
      • L Lost User

        Strange the SQL TRIM would not work How ever , I will give you another solution , with code :

        MyDataTable = New DataTable ();
        SqlConnect con = new SqlConnection ("connection string goes here ") ;
        SqlDataAdapter SqlDa = new SqlDataAdapter ("SELECT * FROM myTable", conn);
        SqlDa.Fill(myDataTable);

        foreach ( DataRow dr in MyDataTable.Rows)
        {
        dr["ColumnName"] = dr["ColumnName"].toString().Trim();
        }

        Hope This Help , ------------ :rose: Please Increase the hit's of my website by 1 ::rose: ----------- www.smart-arab.com

        I know nothing , I know nothing ...

        P Offline
        P Offline
        P T R K
        wrote on last edited by
        #3

        Thank you Stark DaFixzer. I did try this code. But I have 10 million rows. So it will take more time to bind. Please any other solutions. Thanks in Advance Rameshkumar

        L 1 Reply Last reply
        0
        • P P T R K

          Thank you Stark DaFixzer. I did try this code. But I have 10 million rows. So it will take more time to bind. Please any other solutions. Thanks in Advance Rameshkumar

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          I Think that there is a hidden Character at the end of your string that you try trim try to copy the value and paste it , in a word application , OR notepad++ , then press ( Show All Character Button ) it's looks like ( ¶ ) ---- IF you found a hidden chars , which is not a space , then you can remove this char by updating all your records , and re-use the LTRIM (RTRIM) Function again Hope this help , Kind regards

          I know nothing , I know nothing ...

          P 1 Reply Last reply
          0
          • L Lost User

            I Think that there is a hidden Character at the end of your string that you try trim try to copy the value and paste it , in a word application , OR notepad++ , then press ( Show All Character Button ) it's looks like ( ¶ ) ---- IF you found a hidden chars , which is not a space , then you can remove this char by updating all your records , and re-use the LTRIM (RTRIM) Function again Hope this help , Kind regards

            I know nothing , I know nothing ...

            P Offline
            P Offline
            P T R K
            wrote on last edited by
            #5

            Hi Stark DaFixzer, I checked that table. There is no empty space and special characters. Please any other way to trim the values. Thanks in Advance Rameshkumar.T

            P 1 Reply Last reply
            0
            • P P T R K

              Hi Stark DaFixzer, I checked that table. There is no empty space and special characters. Please any other way to trim the values. Thanks in Advance Rameshkumar.T

              P Offline
              P Offline
              P T R K
              wrote on last edited by
              #6

              Hi Stark DaFixzer, I got a solution for trim the values using LINQ. The following statementi have used in my application.

              var NameList = (from param_enum_desc in dsPartnertype.Tables[0].AsEnumerable()
              select new
              {
              POS_VALUE = param_enum_desc.Field<string>("POS_VALUE"),
              POS_DESCR = param_enum_desc.Field<string>("POS_DESCR")
              });

                  stoPartner.DataSource = NameList;
                  stoPartner.DataBind();
              

              Thank you Rameshkumar.T

              P 1 Reply Last reply
              0
              • P P T R K

                Hi Stark DaFixzer, I got a solution for trim the values using LINQ. The following statementi have used in my application.

                var NameList = (from param_enum_desc in dsPartnertype.Tables[0].AsEnumerable()
                select new
                {
                POS_VALUE = param_enum_desc.Field<string>("POS_VALUE"),
                POS_DESCR = param_enum_desc.Field<string>("POS_DESCR")
                });

                    stoPartner.DataSource = NameList;
                    stoPartner.DataBind();
                

                Thank you Rameshkumar.T

                P Offline
                P Offline
                P T R K
                wrote on last edited by
                #7

                Hi Stark DaFixzer, sorry i forgot trim method to end of the statement.

                var NameList = (from param_enum_desc in dsPartnertype.Tables[0].AsEnumerable()
                select new
                {
                POS_VALUE = param_enum_desc.Field<string>("POS_VALUE").Trim(),
                POS_DESCR = param_enum_desc.Field<string>("POS_DESCR").Trim()
                });

                    stoPartner.DataSource = NameList;
                    stoPartner.DataBind();
                

                Thank you Rameshkumar.T

                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