Plusieurs Connexion table access
Bonjour à tous,
J'espere que je poste au bon endroit...
Je réalise une application en vb dotnet et je désire me connecter simultanément à la même base.
Je m'explique , j'ai trois boucle Do while dr.read.....loop imbriqué. Malheuresement on me dit lorsque j'arrive au deuxieme datareader que
Citation:
Un DataReader associé à cette connexion est déjà ouvert, il doit être tout d'abord fermé.
Voici 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 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
|
Dim MyConnection As New System.Data.OleDb.OleDbConnection
Dim MyConnection2 As New System.Data.OleDb.OleDbConnection
Dim MyConnection3 As New System.Data.OleDb.OleDbConnection
MyConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source='C:\Documents and Settings\bdd.mdb'"
MyConnection.Open()
' // déclaration des variables \\
Dim MyCommand As OleDb.OleDbCommand
Dim dr As OleDb.OleDbDataReader
Dim dr2 As OleDb.OleDbDataReader
Dim dr3 As OleDb.OleDbDataReader
Dim requete As String = "....."
Dim nfbi As String
MyCommand = New OleDb.OleDbCommand(requete, MyConnection)
dr = MyCommand.ExecuteReader()
Do While dr.Read
nfbi = dr.GetString(2)
MyConnection2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source='C:\Documents and Settings\bdd2.mdb'"
MyConnection2.Open()
Dim MyCommand2 As OleDb.OleDbCommand
Dim requete2 As String = "......."
MyCommand2 = New OleDb.OleDbCommand(requete2, MyConnection2)
dr2 = MyCommand2.ExecuteReader()
Do While dr2.Read
nfbi2 = dr2.GetString(1)
lfbi2 = dr2.GetString(2)
Dim MyCommand3 As OleDb.OleDbCommand
Dim requete3 As String = "..."
MyCommand3 = New OleDb.OleDbCommand(requete3, MyConnection)
MyCommand3.ExecuteReader()
End If
End If
Loop
MyConnection2.Close()
Loop
MyConnection.Close()
dr.Close() |