heres the code that populates the table
PrivateSub process_gvmoi(ByVal inFile AsString, ByVal outFile AsString)
Dim ifs As FileStream
'Dim ofs As FileStream
ifs =
New FileStream(inFile, FileMode.Open, FileAccess.Read)'ofs = New FileStream(outFile, FileMode.Create, FileAccess.Write)Dim reader As StreamReader'Dim writer As StreamWriterreader =
New StreamReader(ifs)'writer = New StreamWriter(ofs)Dim line AsStringDim cnt AsIntegercnt = 0
Dim vals(15, MAXSIZE) AsStringDim transdate AsStringDim UniqueID AsStringDim TaxID AsStringDim taxIDType AsStringDim appl AsStringDim acctNum AsStringDim transctl AsStringDim transCode AsStringDim creditcash AsStringDim debitcash AsStringDim creditcheck AsStringDim debitcheck AsStringDim transDesc AsStringDim tellerID AsStringDim BranchCode AsStringDim CheckRef AsStringDim CheckNum AsStringDim bankNum AsStringDim cmd AsNew ADODB.Commandcmd.ActiveConnection = conn
cmd.CommandText =
"DELETE * FROM tblGVMOI"cmd.Execute()
cmd =
NothingrecordCount = 0
Me.tdMessage.Text = Me.tdMessage.Text & " ("& cnt & " Records Processed) "WhileNot reader.EndOfStreamIf cnt Mod 100 = 0 ThenIf recordCount = 30 ThenMe.tdMessage.Text = Replace(Me.tdMessage.Text, ".", "")Me.tdMessage.Visible = TrueMe.Refresh()recordCount = 0
EndIfMe.tdMessage.Text = Replace(Me.tdMessage.Text, (cnt - 100), cnt) & "."Me.tdMessage.Visible = TrueMe.Refresh()recordCount += 1
EndIfline = reader.ReadLine()
If line.Length > 2 Thenvals(0, cnt) = line.Substring(0, 8).Trim
'datevals(1, cnt) = line.Substring(8, 16).Trim
vals(2, cnt) = line.Substring(24, 9).Trim
'TaxIDvals(3, cnt) = line.Substring(33, 1).Trim
'TaxID Typevals(4, cnt) = line.Substring(34, 3).Trim
vals(5, cnt) = line.Substring(37, 18).Trim
'acct #vals(6, cnt) = line.Substring(55, 16).Trim
'trans controlvals(7, cnt) = line.Substring(71, 16).Trim
'Trans Control Duplicatevals(8, cnt) = line.Substring(87, 12).Trim
'trans amtvals(9, cnt) = line.Substring(99, 3).Trim
'trans codevals(10, cnt) = line.Substring(102, 63).Trim
'blank field (Dont know)vals(11, cnt) = line.Substring(165, 4).Trim
'branch of transactionvals(12, cnt) = line.Substring(169, 10).Trim
'check #vals(13, cnt) = line.Substring(179, 5).Trim
'bank #vals(14, cnt) = line.Substring(184, 4).Trim
'all # 1 (Dont Know)transdate = convertDate(vals(0, cnt)).PadRight(8)
UniqueID =
""TaxID = vals(2, cnt).PadRight(9)
taxIDType = vals(3, cnt).PadRight(1)
appl =
""'acctNum = vals(5, cnt).PadRight(22)acctNum =
" ".PadRight(22)transctl = vals(6, cnt).PadRight(20)
If vals(9, cnt) = "36"Or vals(9, cnt) = "05"Then'creditcreditcash =
"000000000.00"creditcheck = vals(8, cnt).PadLeft(12,
" ")debitcash =
"000000000.00"debitcheck =
"000000000.00"ElseIf vals(9, cnt) = "55"Or vals(9, cnt) = "94"Then'debitdebitcash =
"000000000.00"debitcheck = vals(8, cnt).PadLeft(12,
" ")creditcash =
"000000000.00"creditcheck =
"000000000.00"Elsecreditcash =
"000000000.00"debitcash =
"000000000.00"creditcheck =
"000000000.00"debitcheck =
"000000000.00"EndIf'transaction CodeIf vals(5, cnt) = "19000020"ThentransCode =
"CC".PadRight(5)ElseIf vals(5, cnt) = "19000091"ThentransCode =
"MO".PadRight(5)ElseIf vals(5, cnt) = "19000088"ThentransCode =
"TC".PadRight(5)ElsetransCode =
" ".PadRight(5)EndIf'trans descIf vals(9, cnt) = "36"ThentransDesc =
"Deposit".PadRight(30)ElseIf vals(9, cnt) = "05"ThentransDesc =
"Credit Memo".PadRight(30)ElseIf vals(9, cnt) = "55"ThentransDesc =
"Debit Memo".PadRight(30)ElseIf vals(9, cnt) = "94"ThentransDesc =
"Check".PadRight(30)ElsetransDesc =
" ".PadRight(30)EndIftellerID =
" ".PadRight(10)BranchCode = vals(11, cnt).PadRight(7)
CheckRef =
" ".PadRight(60)CheckNum = vals(12, cnt).PadRight(35)
bankNum = vals(13, cnt).PadRight(5)
Dim cmd2 AsNew ADODB.CommandDim conn2 AsNew ADODB.Connectionconn2.ConnectionString =
My.Settings.sConnStringconn2.Open()
cmd2.ActiveConnection = conn2
IfCInt(vals(9, cnt)) > 50 Then'Discard transaction codes > 50Elsecmd2.CommandText =
"INSERT INTO tblGVMOI (TransDate, UniqueID, TaxID, TaxIDType, Application, AccountNum, TransCtl, cashcredit, cashdebit, checkcredit, checkdebit, TransCode, TransDesc, TellerID, BranchCode, CheckRef, CheckNum, BankNum) "& _" VALUES('"& transdate & "','"& UniqueID & "','"& TaxID & "','"& taxIDType & "','"& appl & "','"& acctNum & "','"& transctl & "','"& creditcash & "','"& debitcash & "','"& creditcheck & "','"& debitcheck & "','"& transCode & "','"& transDesc & "','"& tellerID & "','"& BranchCode & "','"& CheckRef & "','"& CheckNum & "','"& bankNum & "')"cmd2.Execute()
EndIfcmd2 =
Nothingconn2.Close()
EndIfcnt += 1
EndWhilereader.Close()'writer.Close()EndSubbelow code is used to write to the text file(first line is missing)
PrivateSub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.ClickDim status AsIntegerMe.Validate()Me.TblGVMOIBindingSource.EndEdit()status =
Me.TblGVMOITableAdapter.Update(Me.GvMOIDataSet.tblGVMOI)Me.TblGVMOITableAdapter.Fill(Me.GvMOIDataSet.tblGVMOI)If MsgBox("Update Completed Successfully!", MsgBoxStyle.Information, "Update Completed!") = MsgBoxResult.Ok ThenMe.Close()EndIfEndSubPrivateSub outputGVMOI()Dim ofs As FileStreamofs =
New FileStream(My.Settings.OutFile & "gvmoi.txt", FileMode.Create, FileAccess.Write)Dim writer As StreamWriterwriter =
New StreamWriter(ofs)Dim sql AsStringDim cmd AsNew ADODB.CommandDim rs As ADODB.RecordsetDim conn AsNew ADODB.ConnectionDim transdate AsStringDim uniqueid AsStringDim taxid AsStringDim taxidtype AsStringDim application AsStringDim accountnum AsStringDim transctl AsStringDim cashcredit AsStringDim cashdebit AsStringDim checkcredit AsStringDim checkdebit AsStringDim transcode AsStringDim transdesc AsStringDim tellerid AsStringDim branchcode AsStringDim checkref AsStringDim checknum AsStringDim banknum AsStringDim purchaser AsStringDim beneficiary AsStringDim thirdname AsStringDim check20 AsStringDim check50 AsStringDim check100 AsStringDim check500 AsStringDim check1000 AsStringDim idtype AsStringDim idnum AsStringDim issuedby AsStringDim other AsStringDim address AsStringDim city AsStringDim state AsStringDim zip AsStringconn.ConnectionString =
My.Settings.sConnStringconn.Open()
cmd.ActiveConnection = conn
sql =
"SELECT * FROM tblGVMOI"cmd.CommandText = sql
rs = cmd.Execute
WhileNot rs.EOFtransdate = IIf(IsDBNull(rs(
"TransDate").Value), "", rs("TransDate").Value)uniqueid = IIf(IsDBNull(rs(
"UniqueID").Value), "", rs("UniqueID").Value)taxid = IIf(IsDBNull(rs(
"TaxID").Value), "", rs("TaxID").Value)taxidtype = IIf(IsDBNull(rs(
"TaxIDType").Value), "", rs("TaxIDType").Value)application = IIf(IsDBNull(rs(
"Application").Value), "", rs("Application").Value)accountnum = IIf(IsDBNull(rs(
"AccountNum").Value), "", rs("AccountNum").Value)transctl = IIf(IsDBNull(rs(
"TransCtl").Value), "", rs("TransCtl").Value)cashcredit = IIf(IsDBNull(rs(
"cashcredit").Value), "", rs("cashcredit").Value)cashdebit = IIf(IsDBNull(rs(
"cashdebit").Value), "", rs("cashdebit").Value)checkcredit = IIf(IsDBNull(rs(
"checkcredit").Value), "", rs("checkcredit").Value)checkdebit = IIf(IsDBNull(rs(
"checkdebit").Value), "", rs("checkdebit").Value)transcode = IIf(IsDBNull(rs(
"TransCode").Value), "", rs("TransCode").Value)transdesc = IIf(IsDBNull(rs(
"TransDesc").Value), "", rs("TransDesc").Value)tellerid = IIf(IsDBNull(rs(
"TellerID").Value), "", rs("TellerID").Value)branchcode = IIf(IsDBNull(rs(
"BranchCode").Value), "", rs("BranchCode").Value)checkref = IIf(IsDBNull(rs(
"CheckRef").Value), "", rs("CheckRef").Value)checknum = IIf(IsDBNull(rs(
"CheckNum").Value), "", rs("CheckNum").Value)banknum = IIf(IsDBNull(rs(
"BankNum").Value), "", rs("BankNum").Value)purchaser = IIf(IsDBNull(rs(
"PurchaserName").Value), "", rs("PurchaserName").Value)beneficiary = IIf(IsDBNull(rs(
"BeneficiaryName").Value), "", rs("BeneficiaryName").Value)thirdname = IIf(IsDBNull(rs(
"ThirdName").Value), "", rs("ThirdName").Value)check20 = IIf(IsDBNull(rs(
"checkdenom20").Value), "", rs("checkdenom20").Value)check50 = IIf(IsDBNull(rs(
"checkdenom50").Value), "", rs("checkdenom50").Value)check100 = IIf(IsDBNull(rs(
"checkdenom100").Value), "", rs("checkdenom100").Value)check500 = IIf(IsDBNull(rs(
"checkdenom500").Value), "", rs("checkdenom500").Value)check1000 = IIf(IsDBNull(rs(
"checkdenom1000").Value), "", rs("checkdenom1000").Value)idtype = IIf(IsDBNull(rs(
"IDType").Value), "", rs("IDType").Value)idnum = IIf(IsDBNull(rs(
"IDNum").Value), "", rs("IDNum").Value)issuedby = IIf(IsDBNull(rs(
"IDIssuedBy").Value), "", rs("IDIssuedBy").Value)other = IIf(IsDBNull(rs(
"IDOthers").Value), "", rs("IDOthers").Value)address = IIf(IsDBNull(rs(
"PurchaserAddress").Value), "", rs("PurchaserAddress").Value)city = IIf(IsDBNull(rs(
"PurchaserCity").Value), "", rs("PurchaserCity").Value)state = IIf(IsDBNull(rs(
"PurchaserState").Value), "", rs("PurchaserState").Value)zip = IIf(IsDBNull(rs(
"PurchaserZip").Value), "", rs("PurchaserZip").Value)transdate = transdate.PadRight(8)
uniqueid = uniqueid.PadRight(24)
taxid = taxid.PadRight(9)
taxidtype = taxidtype.PadRight(1)
application = application.PadRight(5)
accountnum = accountnum.PadRight(22)
transctl = transctl.PadRight(20)
cashcredit = cashcredit.PadLeft(12,
" ")cashdebit = cashdebit.PadLeft(12,
" ")checkcredit = checkcredit.PadLeft(12,
" ")checkdebit = checkdebit.PadLeft(12,
" ")transcode = transcode.PadRight(5)
transdesc = transdesc.PadRight(30)
tellerid = tellerid.PadRight(10)
branchcode = branchcode.PadRight(7)
checkref = checkref.PadRight(60)
checknum = checknum.PadRight(35)
banknum = banknum.PadRight(5)
purchaser = purchaser.PadRight(40)
beneficiary = beneficiary.PadRight(40)
thirdname = thirdname.PadRight(40)
check20 = check20.PadLeft(5,
" ")check50 = check50.PadLeft(5,
" ")check100 = check100.PadLeft(5,
" ")check500 = check500.PadLeft(5,
" ")check1000 = check1000.PadLeft(5,
" ")idtype = idtype.PadRight(1)
idnum = idnum.PadRight(22)
issuedby = issuedby.PadRight(2)
other = other.PadRight(40)
address = address.PadRight(35)
city = city.PadRight(22)
state = state.PadRight(2)
zip = zip.PadRight(5)
writer.WriteLine(transdate + uniqueid + taxid + taxidtype + application + accountnum + transctl + cashcredit + cashdebit + checkcredit + checkdebit + transcode + transdesc + tellerid + branchcode + checkref + checknum + banknum + purchaser + beneficiary + thirdname + check20 + check50 + check100 + check500 + check1000 + idtype + idnum + issuedby + other + address + city + state + zip)rs.MoveNext()
EndWhilers.Close()
cmd =
Nothingconn.Close()
writer.Close()
EndSub