Bonjour j'ai un petit problème d'"insert into" dans une table, j'importe le calendrier de outlook, je fais une boucle FOR ... NEXT pour copier les éléments dans ma table voici un extrait de mon code:

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
34
35
36
37
38
39
40
41
42
43
44
45
46
   For i = 1 To lngItemCount
 
            On Error Resume Next
            objItem = oCal.Items(i)
            On Error GoTo 0
 
            If Not objItem Is Nothing Then ' this is an appointment item
 
                With objItem
                    début = Format(.Start, "dd/mm/yyyy hh:mm") 'Début
                    fin = Format(.End, "dd/mm/yyyy hh:mm") ' Fin
                    date1 = Format(.End, "dd/mm/yyyy") ' Date
                    duree = Format((.Duration / 1440) / 1, "hh:mm") ' Durée
                    objet = .Subject ' Objet
                    nom = .Location ' Nom
                    de = .Organizer ' De
                    body = Replace(.Body, "&0A", vbCrLf) 'Contenu
                    categories = .Categories ' Categories
                End With
 
                'objItem = Nothing
            End If
            'Instancier un objet Commande
            ObjetCommand = New OleDbCommand
            ObjetCommand.Connection = ObjetConnection
            ObjetCommand.CommandType = CommandType.Text
            ObjetCommand.CommandText = "INSERT INTO Calendar_net ( [Date], [début], [Fin], [Durée], [Objet], [Nom], [De], [Contenu], [Categories] ) VALUES ('" & date1 & "', '" & début & "', '" & fin & "', '" & duree & "', '" & objet & "', '" & nom & "', '" & de & "', '" & body & "', '" & categories & "')"
            ObjetCommand.ExecuteNonQuery()
 
            tmp = tmp + 1 '(oItems.Count / 8) 
            ProgressBar1.Value = tmp
 
            ' Nettoyage
            oApp = Nothing
            oNS = Nothing
            début = Nothing
            fin = Nothing
            date1 = Nothing
            duree = Nothing
            objet = Nothing
            nom = Nothing
            de = Nothing
            body = Nothing
            categories = Nothing
 
        Next i
j'ai un problème avec:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
ObjetCommand.CommandText = "INSERT INTO Calendar_net ( [Date], [début], [Fin], [Durée], [Objet], [Nom], [De], [Contenu], [Categories] ) VALUES ('" & date1 & "', '" & début & "', '" & fin & "', '" & duree & "', '" & objet & "', '" & nom & "', '" & de & "', '" & body & "', '" & categories & "')"
si je laisse les VALUES en variable, il me fait un 1er traitement, il va jusqu'à "Next i" puis remonte à "For i" il lit tout jusqu'à "ObjetCommand.ExecuteNonQuery()" et sur la commande il bloque...

si je change ma commande et je remplace les variables par du texte:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
 ObjetCommand.CommandText = "INSERT INTO Calendar_net ( [Date], [début], [Fin], [Durée], [Objet], [Nom], [De], [Contenu], [Categories] ) VALUES ('09/15/2010', '09/30/2010 02:30', '09/15/2010 04:15', 'h:mm', '0000000', 'non de l'article', 'name', '', 'derniere minute')"
la ca marche, j'ai 100 lignes identique dans ma table mais ca marche,

je sais pas trop, mais j'ai l'impression qu'en mettant à jour les variables il bug ???