StringBuilder and dataset

J

JenHu

Hi experts,

I received a sample from bank for the header record in the output file
(attached at the bottom).

I want to use same method to have a stringbuilder to arrange the fix
length positions, and the fields will be retrieved from database and
put into the dataset. But I am familiar at how to use dataset and
put into .insert stringbuilder. Here is the code that I am working
on (the function should return 1 string line at a time. The loop of
reading rows will be controled in main form): Can someone show me
how to retrieve a column, say LastName and put into
strResult.Insert()??? Thanks.

Imports System.Data.SqlClient
Module Module1
Public Function GenerateA(ByRef strEmpID As String, ByRef
strClientAcct As String, ByRef strAcctStatus As String, ByRef
strAddressFlag As String, ByRef strNameFlag As String)
Dim strResult As New System.Text.StringBuilder
Dim GPConnection As SqlConnection
Dim dr As SqlDataReader
Dim GPDataset As New DataSet

GPConnection = New
SqlConnection("............................")
Dim GPDataAdapter As New SqlDataAdapter("SELECT
LASTNAME,FRSTNAME,MIDLNAME,PHONE1,BRTHDATE FROM UPR00102 where
EmployID="+strEmpID,GPConnection)
Try
GPConnection.Open()
GPDataAdapter.Fill(GPDataset, "AcctInfoTble")
Dim DS As DataSet = New DataSet
'position 1 20A
strResult.Insert ?????????????????

Catch ex As Exception
MessageBox.Show(ex.ToString)
Finally
GPConnection.Dispose()
End Try
Return strResult.ToString
End Function
End Module


-------------------------------------------------------------------------------------
Module GenerateFile

Public Function GenerateFH(ByRef strCompanyName As String, ByRef
strTopCorp As String, ByRef strBatchNum As String, ByRef dtFileDate
As Date)
Dim strResult As New System.Text.StringBuilder
strResult.Capacity = 731
'Position 1 2A FH
strResult.Insert(0, "FH")
'Position 3 10A Header Date
strResult.Insert(2, dtFileDate.Date.Year & "/" &
dtFileDate.Date.Month.ToString.PadLeft(2, "0") & "/" &
dtFileDate.Date.Day.ToString.PadLeft(2, "0"))
'Position 13 8A Header Time
strResult.Insert(12,
dtFileDate.TimeOfDay.Hours.ToString.PadLeft(2, "0") & ":" &
dtFileDate.TimeOfDay.Minutes.ToString.PadLeft(2, "0") & ":" &
dtFileDate.TimeOfDay.Seconds.ToString.PadLeft(2, "0"))
'Position 21 10A Transfer File Version
strResult.Insert(20, "4.0".PadRight(10, " "))
'Position 31 10A Product Type
strResult.Insert(30, "EFUNDS".PadRight(10, " "))
.............
Return strResult.ToString
End Function
End Module
---------------------------------------------------------------------------

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top