voila en fait apres avoir recupere un ficher text,je recupere ligne par ligne et ensuite je prends la sous chaine ki m'interesse c'est a dire pour etre plus clair
je recupere par exemple la ligne suivante:
"je suis content" et moi ce ki m'interesse c "suis" donc j'utilise un substring je dispose du code suivant:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 
        Dim ConnectionString As String = "Data Source=SM65CVDF;Initial Catalog=GESTION;Integrated Security=True"
 
        Dim con As New SqlConnection(ConnectionString)
        con.Open()
 
 
        Dim objfso As System.Object
        objfso = CreateObject("Scripting.FileSystemObject")
 
        Dim file As Object
        file = objfso.OpenTextFile("I:\expl\PYRAMIDE\PYRAMIDE.txt", 1, False)
        Dim TL As String
        executeRequete("delete from PYRAMIDE")
        Do While Not file.AtEndOfStream
            TL = file.readline()
            MsgBox("Ligne lue: " & TL)
            'Dim res As String = TL.Substring(5, 5)
            Dim cmd As New SqlCommand("insert into PYRAMIDE(DirectionRegionale) values (TL.substring(5,5))", con)
            Dim writer As Int32 = cmd.ExecuteNonQuery()
            'res = TL.Substring(15, 5)
            Dim cmd1 As New SqlCommand("insert into PYRAMIDE(Groupe) values(TL.Substring(15, 5)) ", con)
            Dim writer1 As Int32 = cmd.ExecuteNonQuery()
            'res = TL.Substring(25, 5)
            Dim cmd2 As New SqlCommand("insert into PYRAMIDE(Groupe) values(TL.Substring(25, 5))", con)
            Dim writer2 As Int32 = cmd.ExecuteNonQuery()
            'res = TL.Substring(35, 300)
            'Dim cmd3 As New SqlCommand(res, con)
            Dim writer3 As Int32 = cmd.ExecuteNonQuery()
 
 
 
        Loop
mais quand je compile mon code il m'affiche ke mon TL.substring est non valide,comprend pas,veut un coup de main merci..