Program Logic to summaries Data

Posted on 2005-04-16
Medium Priority
Last Modified: 2010-04-23
I have a stored Procedure which returns me route Information to build a route table. The return data looks like the sample below

I have a app which queries a MS Sql Table which returns me Phone nbr Prefixes,Start and End Nbrs
The field is called prefix ,start,end and has data like

Prefix                Trunk          
213232            Trunk 1
213235            Trunk 1                
213238            Trunk 1                
213239            Trunk 1              
213242            Trunk 2                
213243            Trunk 1          
213446            Trunk 1

to save space in my other apps i need to be able to get to be able to find all continues blocks and then summaries them like this

Start+ End       Start                        End           Trunk
213232_239     213232                    213239      Trunk 1
213242            213242                    213242      Trunk 2
213243_446     213446                    213446      Trunk 1

Question by:AlexPonnath
  • 2
LVL 14

Accepted Solution

amyhxu earned 1500 total points
ID: 13800223
Is the second table an existing table in SQL? If so, you can generate a datatable based on the table in SQL; if not, you'll write code to generate the table structure in both dataset and SQL.
Suppose your stored procedure is used to generate a table named "tbl1", and your result table is called "tbl2". They are both in the same dataset "myDataSet".

Dim StartNewRow As Boolean = True
Dim Trunk As String
Dim newRow As DataRow

For Each dRow As DataRow In myDataSet.Tables("tbl1").Rows
    StartNewRow = Not (Trunk = dRow("Trunk"))
    If StartNewRow Then
        If Not newRow Is Nothing Then
        End If
        newRow = myDataSet.Tables("tbl2").NewRow
        Trunk = dRow("Trunk")
        newRow("StartEnd") = dRow("Prefix")
        newRow("Start") = dRow("Prefix")
        newRow("End") = dRow("Prefix")
        newRow("Trunk") = dRow("Trunk")
        newRow("StartEnd") = newRow("StartEnd").SubString(0, 6) & "_" & CStr(dRow("Prefix")).SubString(3, 3)
        newRow("End") = dRow("Prefix")
    End If

' Add last new row to tbl2
If Not newRow Is Nothing Then
    newRow = Nothing
End If


Author Comment

ID: 13800895
yje first one is a Table in SQl Server, the second one is the output i like to save to a Text file
based on the Query and the logic..

Author Comment

ID: 13800923
Also i would like not to use a dataset if posible but rather use a data reader

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question