Un DataReader dans un autre DataReader
Bonjour,
Est-ce possible de créer un DataReader dans un autre ?
Par exemple, j'ai un code de ce type :
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
|
Command SelectCommand = new Command("RequeteSQL", MaConnection);
DataReader MonReader = SelectCommand.ExecuteReader();
MonReader.Read();
if (MonReader.HasRows)
{
Command SelectCommand2= new Command("RequeteSQL", MaConnection);
DataReader MonReader2 = SelectCommand2.ExecuteReader();
MonReader2.Read();
if (MonReader2.HasRows)
{
Commande InsertCommand = new Command("RequeteSQL", MaConnection);
InsertCommand.Parameters.AddWithValue("parameter", value);
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
InsertCommand.ExecuteNonQuery();
}
MonReader2.Close();
}
MonReader.Close(); |
Pour moi, ça a l'air correct mais au moment de l'exécution de la requête d'ajout, j'ai une erreur me disant que je dois fermer un DataReader :
Citation:
There is already an open DataReader associated with this Command which must be closed first.
Y a-t-il une solution ?
Merci d'avance.