Bonjour,

je suis stagiaire et je galère depuis 3 jours avec les erreurs que me sort VB.NET pour l'import de données sous Acces...

voilà sous Access, j'ai ma première requête qui affiche ceci :

INSTRUMENTID POSITION ISSUER RESULTPV
71873 Pay ALLEIC 166945125,829102
71874 Pay LEHMAN 396,027241004398
71875 Pay MERRYL.LN 56099,4839687515
72006 Pay LEHMAN 32126,8116420857
72007 Pay MERRYL.LN 134240,160682819
72008 Pay ALLEIC 32580,0864936687
72174 Pay ALLEIC 157821,312087686

72175 Pay ALLEIC 20220,9153636273
et ma 2eme requête qui affiche la table suivante :

INSTRUMENTID DEFINITIONELEMENT VALUE
71873 ALLIEC3M40 2,05896
71873 ALLIEC3M40 1,89238
71873 ALLIEC3M40 1,41104
71873 ALLIEC3M40 1,47061
71873 ALLIEC3M40 1,54272
71873 ALLIEC3M40 2,27867
71873 ALLIEC3M40 1,72844
71874 LEHMAN 2,0036
71874 LEHMAN 2,91575
71874 LEHMAN 4,09925
71874 LEHMAN 2,5701
71874 LEHMAN 2,1866
71874 LEHMAN 2,43391
71874 LEHMAN 1,86408
71875 MERRYLL3M40 1,95995
71875 MERRYLL3M40 2,09589
71875 MERRYLL3M40 1,66754
71875 MERRYLL3M40 2,27434
71875 MERRYLL3M40 1,60595
71875 MERRYLL3M40 1,62
71875 MERRYLL3M40 1,85
72006 LEHMAN 2,1866
72006 LEHMAN 2,5701
72006 LEHMAN 2,43391
72006 LEHMAN 2,0036
72006 LEHMAN 1,86408
72006 LEHMAN 4,09925
72006 LEHMAN 2,91575
72007 MERRYLL3M40 2,27434
72007 MERRYLL3M40 1,62
72007 MERRYLL3M40 2,09589
72007 MERRYLL3M40 1,95995
72007 MERRYLL3M40 1,85
72007 MERRYLL3M40 1,60595
72007 MERRYLL3M40 1,66754
72008 ALLIEC3M40 1,54272
72008 ALLIEC3M40 2,27867
72008 ALLIEC3M40 1,41104
72008 ALLIEC3M40 1,72844
72008 ALLIEC3M40 2,05896
72008 ALLIEC3M40 1,47061
72008 ALLIEC3M40 1,89238
72174 ALLIEC3M40 2,05896
72174 ALLIEC3M40 1,89238
72174 ALLIEC3M40 2,27867
72174 ALLIEC3M40 1,41104
72174 ALLIEC3M40 1,54272
72174 ALLIEC3M40 1,72844
72174 ALLIEC3M40 1,47061
72175 ALLIEC3M40 1,72844
72175 ALLIEC3M40 1,41104
72175 ALLIEC3M40 1,54272
72175 ALLIEC3M40 1,89238
72175 ALLIEC3M40 2,27867
72175 ALLIEC3M40 1,47061
72175 ALLIEC3M40 2,05896
Ce que je souhaite, c'est de transposer la champ value; par exemple pour l'instrument 71873, je veux qu'il m'affiche en une seule ligne (en faisant 7 colonnes biensur)

cc1 cc2 cc3 cc4 cc5 cc7 cc10
2,05896 1,89238 1,41104 1,47061 1,54272 2,27867 1,72844
j'ai fait un petit code sur VB.NET; mais mon problème est de vouloir importer ces données dans une table INPUTS, j'ai écris mon programme mais je ne comprends pas mes erreurs d'exception. Voici le code bien légendé :

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
    Public Sub Import_CDS1()
        Dim Rset As Integer
        Dim Cset As Integer
        Dim nada As String
 
        Rset = 0
 
        MyConnexion.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:\Antoine\CVaR\CreditVaR_PR.mdb"
        MyCommand = MyConnexion.CreateCommand()
        MyCommand1 = MyConnexion.CreateCommand()
        MyCommand2 = MyConnexion.CreateCommand()
 
        'Nettoyage de la table INPUTS
        MyCommand.CommandText = "DELETE INPUTS.* FROM INPUTS;"
        MyConnexion.Open()
        MyReader = MyCommand.ExecuteReader()
        MyReader.Close()
        MyConnexion.Close()
 
 
        'Récupération des data NON retraitées pour Mise à Jour de la table INPUTS
 
        MyCommand1.CommandText = "Ma 1ere requête SQL"
        MyAdapter = New OleDbDataAdapter(MyCommand1)
        MyConnexion.Open()
        MyReader1 = MyCommand1.ExecuteReader() 'PROBLEME ICI
 
        If MyReader1.HasRows = False Then
            MsgBox("Requête Vide", MsgBoxStyle.Exclamation)
            Exit Sub
        End If
 
        Do While MyReader1.Read()
            nada = MyReader1.GetString(1)
            Rset = Rset + 1
        Loop
 
        Nb_Obligors = Rset
 
        ReDim CC(Nb_Obligors, 7)
        MyReader1.Close()
        MyReader1 = MyCommand1.ExecuteReader()
 
        'Avec l'aide de la propriété Fill du DataAdapter charger le DataSet
        MyAdapter.Fill(MyDataSet, "INPUTS")
        'On met alors dans un Objet DataTable une table du DataSet
        MyDataTab = MyDataSet.Tables("INPUTS")
        MyDataRow = MyDataSet.Tables("INPUTS").NewRow()
 
        'On crée alors une nouvelle ligne pour chaque point de la distribution
        For Rset = 1 To Nb_Obligors
 
            MyDataRow = MyDataSet.Tables("INPUTS").NewRow()
            MyReader1.Read()
 
            'On lui implémente les valeurs des champs 
            MyDataRow("INSTRUMENTID") = MyReader1.GetValue(MyReader1.GetOrdinal("INSTRUMENTID"))
            MyDataRow("CREDITID") = MyReader1.GetValue(MyReader1.GetOrdinal("ISSUER"))
            MyDataRow("POSITION") = MyReader1.GetValue(MyReader1.GetOrdinal("POSITION"))
            MyDataRow("PRINCIPAL") = MyReader1.GetValue(MyReader1.GetOrdinal("PRINCIPALAMOUNT"))
            MyDataRow("STARTDATE") = MyReader1.GetValue(MyReader1.GetOrdinal("STARTDATEUNADJ"))
            MyDataRow("MATURITY") = MyReader1.GetValue(MyReader1.GetOrdinal("MATURITYDATEUNADJ"))
            MyDataRow("RECOVERY") = MyReader1.GetValue(MyReader1.GetOrdinal("FIXEDRECRATE"))
            MyDataRow("CONTRACTSPREAD") = MyReader1.GetValue(MyReader1.GetOrdinal("INTERESTFIXEDRATE"))
            MyDataRow("FREQ") = MyReader1.GetValue(MyReader1.GetOrdinal("DATESPAYMENTFREQ"))
            MyDataRow("RATING") = ""
            MyDataRow("MtM") = MyReader1.GetValue(MyReader1.GetOrdinal("RESULTPV"))
            MyDataRow("DEFAULTPROBABILITY") = 0.02 'Attention , PANO n'archive pas les proba, il faudra les recalculer : RESTE A FAIRE !!!
            MyDataRow("MARKETCORRELATION") = Beta(Rset)
            MyDataRow("EXPECTEDLOSS") = (1 - MyDataRow("RECOVERY")) * MyDataRow("PRINCIPAL") * MyDataRow("DEFAULTPROBABILITY")
            MyDataRow("UNEXPECTEDLOSS") = (1 - MyDataRow("RECOVERY")) * MyDataRow("PRINCIPAL") * Math.Sqrt(MyDataRow("DEFAULTPROBABILITY") * (1 - MyDataRow("DEFAULTPROBABILITY")))
 
            'Ici on ajoute une ligne(row) à notre dataset
            MyDataSet.Tables("INPUTS").Rows.Add(MyDataRow)
 
        Next Rset
 
        Dim MyCommandBuilder1 As New OleDbCommandBuilder(MyAdapter)
        'Mise à jour de la table INPUTS
        MyAdapter.Update(MyDataSet, "INPUTS")
        MyDataSet.Clear()
 
 
        'Récupération des data à retraiter pour Mise à Jour de la table INPUTS
        MyCommand2.CommandText = "Ma 2eme requête SQL"
 
        MyAdapter = New OleDbDataAdapter(MyCommand2)
        MyReader = MyCommand2.ExecuteReader()
        MyAdapter.Fill(MyDataSet, "INPUTS")
        MyDataTab = MyDataSet.Tables("INPUTS")
 
        'Alimentation variables CC pour chaque émetteur (Rset), on a 7 plots (Cset)
        'On transpose la colonne Value en ligne pour chaque plot!
        For Rset = 1 To Nb_Obligors
            For Cset = 1 To 7
                CC(Rset, Cset) = MyReader.GetValue(MyReader.GetOrdinal("VALUE"))
                MyReader.Read()
            Next Cset
        Next Rset
        MyReader.Close()
 
        'On inscrit les points de courbe pour chaque émetteur dans la table INPUTS
        For Rset = 1 To Nb_Obligors
 
            MyDataRow = MyDataSet.Tables("INPUTS").NewRow()
            'Durée format 'numeric "y"'
            MyDataRow("TERM") = MyReader.GetValue(MyReader.GetOrdinal("MATURITYDATETERM"))
 
            Term(Rset) = Mid(Term(Rset), 1, 1)
            Select Case Term(Rset)
                Case "7"
                    MyDataRow("MARKETSPREAD") = CC(Rset, CInt(Term(Rset)) - 1)
                Case "10"
                    MyDataRow("MARKETSPREAD") = CC(Rset, CInt(Term(Rset)) - 3)
                Case Else
                    MyDataRow("MARKETSPREAD") = CC(Rset, CInt(Term(Rset)))
            End Select
            MyDataRow("CC1") = CC(Rset, 1)
            MyDataRow("CC2") = CC(Rset, 2)
            MyDataRow("CC3") = CC(Rset, 3)
            MyDataRow("CC4") = CC(Rset, 4)
            MyDataRow("CC5") = CC(Rset, 5)
            MyDataRow("CC7") = CC(Rset, 6)
            MyDataRow("CC10") = CC(Rset, 7)
 
            MyDataSet.Tables("INPUTS").Rows.Add(MyDataRow)
 
        Next Rset
 
        'Pour modifier les valeurs changées dans le DataAdapter
        Dim MyCommandBuilder2 As New OleDbCommandBuilder(MyAdapter)
        'Mise à jour
        MyAdapter.Update(MyDataSet, "INPUTS")
        'On vide le DataSet
        MyDataSet.Clear()
        MyConnexion.Close()
 
    End Sub
Ne me dites pas de faire une requête Ajout parce que j'ai dejà essayé et j'ai un problème quand je veux mettre le champ value, je n'arrive pas à transposer en ligne.

SVP aidez-moi