import fichier txt dans sql server
bonjour,
voila je suis obliger de monter un petit programme vb pour importer un fichier
.txt que je collecte d 'une application tierce.
le fichier txt récupérer est composer de 4 champs séparer par tabulation
L 125 458 fiche1
L 125 458 fiche2
L 125 458 fiche3
grosse problematique le fichier txt Pése à peux prés 800 mégas
j arrive a lire le fichier ligne a ligne mais par contre je n arrive pas a l'insérer dans ma base de donnée
voila mon code :
Code:
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 |
le code si dessus ne fonctionne pas mais cest tous ce que j ai trouver sur le net pour inserer un fichier txt dans une base sql
un petit coup de pouce serait vraiment bienvenu
ps : j arrive a injecter le fichier text via un ssis de mon sql server 2005
mais apparament on peux pas lancer les ssis si l ampli n est pas sur le serveur lui meme ?