Reading Multiple Text File and Update in Access

lccengr

Member
Joined
Mar 27, 2009
Messages
15
Programming Experience
Beginner
Hi All,

I am trying to select Multiple files and then read the file 1 by 1, i want to know how to specify the file number in Visual Basic .net 2008

Here is a sample code which i have used in reading the text file.

With dlgOpen
.Filter = "txt Files (*.txt)|*.txt"
.Title = "Open Text Files"
.FileName = ""
End With
results = dlgOpen.ShowDialog
If results = DialogResult.OK Then
filereader = New StreamReader(dlgOpen.FileName)
TextBox1.Text = filereader.ReadToEnd()
filereader.Close()
End If


Actually my text file is a dump file and i need to make a program to process this dump file. I may ask some stupid questions but this is just a beginning, i want to parse INDIVIDUAL text file line by line. In the above code i have used the ReadToEnd function in order to display it in TextBox but i may use ReadLine Function or Read function to read line by line or characters respectively.

I have attached an Access Database with the predefined tables in it, I want to update the contents in Access Database. Supposingly if my textfile contains Names (Sam,Julie,Joseph,Marina), how will i update my attached Access table in vertical order !

I will appreciate if experts provide a detailed help, thank you
 
I think i am able to read 1 by 1 files by the following code.

Dim File_name As Array
Dim DB_File As String
With dlgOpen
.Filter = "Text Files(*.txt)|*.txt"
.Title = "Text Files"
.FileName = ""
End With

results = dlgOpen.ShowDialog
File_name = dlgOpen.FileNames
FileCount = dlgOpen.FileNames.Count

For lngcounter = 0 To FileCount - 1
DB_File = File_name(lngcounter)
If results = DialogResult.OK Then
filereader = New StreamReader(DB_File)
TextBox1.Text = filereader.ReadToEnd()
filereader.Close()
End If
Next

But when i display it in Textbox, i see that 1 text file is displayed at a time, that is what i want, but i want this file to process now. My Text file contains raw data. I have to read it line by line or character in order to process.

Supposing my File Contains
CLASSA:John,Joseph,Julie,Harry;CLASSB:Angelina,Josephine,Maria,Connely


then how will i arrange it in
CLASSA
John
Joseph
Julie
Harry

CLASSB
Angelina
Josephine
Maria
Connely

I need to update in Access Database as well, please also tell me how will i update it in two different columns of Access. My multiple file contains different names, that is why i want to add these names in a column of ACCESS database and process each file individually !
 
Back
Top