Avatar of kdeutsch
kdeutschFlag for United States of America

asked on 

adding information from sql query for text file

the Follwoing code exports information to a text file.  I need to change it slightly so that it adds all the pay information as a total and then writes it to the header line.  I commented in code what needs to happen or is happening.

sql = "select s.sidstrNAME_IND, s.sidstrST_ADDR, s.sidstrADDR_CITY, s.sidstrSTATES_US, s.sidstrZIP_CODE, p.strPayPeriod, " _
            & "p.strTotalEntitlement, p.strTTWH, p.strMilesPay FROM      cms.dbo.tblsidpers as s INNER JOIN tblSadPay as p on " _
            & "p.strSSN = s.sidstrSSN_SM where dtPayPaid is not null and p.intUICID = (select intUICID from tblUIC " _
            & "where intTaskForceID = " & ddlTaskForce.SelectedValue & " and strUIC = '" & DDLUIC.SelectedValue & "') " _
            & "UNION " _
            & "select s.strName, s.strAddress, s.strCity, s.strState, s.strZip, p.strPayPeriod, p.strTotalEntitlement, p.strTTWH, p.strMilesPay " _
            & "FROM MNAIrForcePersonnel.dbo.tblMnAirPersonnel as s INNER JOIN tblSadPay as p on p.strSSN = s.strSSN  " _
            & "where dtPayPaid is not null and p.intUICID = (select intUICID from tblUIC where intTaskForceID = " & ddlTaskForce.SelectedValue & " " _
            & "and strUIC = '" & DDLUIC.SelectedValue & "') order by s.sidstrNAME_IND"

        myDataTable = New DataTable
        myDataTable = getData(sql)

        theCounter = 1

        For Each myDataRow In myDataTable.Rows
            Name = addSpaces(myDataRow(0), 45)
            StAddr = addSpaces(myDataRow(1), 50)
            City = addSpaces(myDataRow(2), 15)
            State = addSpaces(myDataRow(3), 2)
            Zip = addSpaces(myDataRow(4), 9)

            payRow = payStart & addSpaces(CStr(theCounter), 17)
            theCounter = theCounter + 1

            milesRow = milesStart & addSpaces(CStr(theCounter), 17)
            theCounter = theCounter + 1

            tempLine = Name & addSpaces("", 90) & StAddr & City & State & Zip

            payRow += tempLine & addSpaces(myDataRow(5), 30) & "00" & formatPay(CDbl(myDataRow(6)) - CDbl(myDataRow(7))) & addSpaces("", 10)
            milesRow += tempLine & addSpaces("Miles", 30) & "00" & formatPay(CDbl(myDataRow(8))) & addSpaces("", 10)
???????????????????
For the mydatarow 7 & 8 I need to add these all together when the loop is done and then add them into a healer line which is above this code.


            theFile.WriteLine(payRow)
            theFile.WriteLine(milesRow)
        Next

        theFile = Nothing
        fso = Nothing
ASP.NETVisual Basic.NET

Avatar of undefined
Last Comment
kdeutsch
Avatar of ChetOS82
ChetOS82
Flag of United States of America image

What object is "theFile"?
Avatar of kdeutsch
kdeutsch
Flag of United States of America image

ASKER

theFile is from code not shown  that calls out the file to write it to a text file.
 theFile = fso.CreateTextFile(Server.MapPath("..\Voucher") & "\ADM.GF.SYST.IWP.S077.TEST1", True)
ASKER CERTIFIED SOLUTION
Avatar of ChetOS82
ChetOS82
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of kdeutsch
kdeutsch
Flag of United States of America image

ASKER

Your description is what is happening.  But what i am tyring to do now is capture the sum of all data that loops thorugh data.rows 7 and 8 and sum it up.
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo