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. Visual Basic
  4. looking for more efficient way to concatinate values in a datatable

looking for more efficient way to concatinate values in a datatable

Scheduled Pinned Locked Moved Visual Basic
performancedatabasehelp
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.
  • C Offline
    C Offline
    camatulli
    wrote on last edited by
    #1

    i'm having an major performance issue with a concatination query i wrote against a datatable and was looking for a way to either speed up the query or a whole nother way of doing it which performs better... at present my app spends 2 min processing this one loop, while i can do the two loops individually in about 5 seconds. Here is the code: For Each dr As DataRow In Main.DS_New.Tables(RightTable).Select(filter, "location,type desc") Dim CATValues As String = Nothing If dr.RowState <> DataRowState.Deleted And dr.RowState <> DataRowState.Detached Then Select Case dr("name").ToString.ToLower Case "value" For Each DRsameLocation As DataRow In Main.DS_New.Tables(RightTable).Select(filter & " AND PK<>" & dr("PK") & " AND Location='" & dr("Location") & "' AND type='" & dr("type") & "' AND Name='" & dr("Name") & "'") CATValues += Chr(215) & DRsameLocation("loc") & Chr(214) & DRsameLocation("value") DRsameLocation.Delete() Next If CATValues = Nothing Then dr("value") = dr("loc") & Chr(214) & dr("value") Else dr("value") = dr("loc") & Chr(214) & dr("value") & CATValues dr("loc") = "MV" End If End Select End If Next

    D 1 Reply Last reply
    0
    • C camatulli

      i'm having an major performance issue with a concatination query i wrote against a datatable and was looking for a way to either speed up the query or a whole nother way of doing it which performs better... at present my app spends 2 min processing this one loop, while i can do the two loops individually in about 5 seconds. Here is the code: For Each dr As DataRow In Main.DS_New.Tables(RightTable).Select(filter, "location,type desc") Dim CATValues As String = Nothing If dr.RowState <> DataRowState.Deleted And dr.RowState <> DataRowState.Detached Then Select Case dr("name").ToString.ToLower Case "value" For Each DRsameLocation As DataRow In Main.DS_New.Tables(RightTable).Select(filter & " AND PK<>" & dr("PK") & " AND Location='" & dr("Location") & "' AND type='" & dr("type") & "' AND Name='" & dr("Name") & "'") CATValues += Chr(215) & DRsameLocation("loc") & Chr(214) & DRsameLocation("value") DRsameLocation.Delete() Next If CATValues = Nothing Then dr("value") = dr("loc") & Chr(214) & dr("value") Else dr("value") = dr("loc") & Chr(214) & dr("value") & CATValues dr("loc") = "MV" End If End Select End If Next

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      This would probably be better done on the database side with a stored procedure. Look into the COALESCE sql function.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      C 1 Reply Last reply
      0
      • D Dave Kreskowiak

        This would probably be better done on the database side with a stored procedure. Look into the COALESCE sql function.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008

        C Offline
        C Offline
        camatulli
        wrote on last edited by
        #3

        unfortunatly since the data is in a datatable, and not in SQL, that is not an option.

        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