1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
Dim countligne1 As Integer = 0
Dim PCLINK_LTableAdapter As New SetTableAdapters.PCLINK_LTableAdapter
Using file As New IO.FileStream("D:\Lsav.txt", IO.FileMode.Open, IO.FileAccess.Read)
'Creating a strem to read the file into text
Using stream As New IO.StreamReader(file)
'Read the entire file, split it into line arrays by CRLF, and loop through it.
For Each sLine As String In stream.ReadToEnd().Split(Environment.NewLine)
'You to use ", as the delimiter to ensure that commas inside a record are ignored.
Dim sDelimiters() As String = {"\t"}
'Now split the line into individual records.
Dim sRecords() As String = sLine.Split(sDelimiters, StringSplitOptions.None)
countligne1 += 1
'Insert them into the database by referencing the individual string in the array,
'but be sure to replace the quotes with an emtpy string; otherwise, you will have quote in the record.
'The third argument, to which I'm passing a 'Nothing', is expecting a picture.
PCLINK_LTableAdapter.Insert(sRecords(0), sRecords(1), sRecords(2), sRecords(3))
With listaction.Items
.Add(String.Format("lignes : " & sRecords(0)))
End With
Next
End Using
End Using |
Partager