slt tout le monde.
pour exécuter une commande SQL j'ai développé la méthode static suivante:
en suite pour executer ma requete je fais:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 static public SqlCommand Command { get { if(s_cmd==null) { s_cmd = new SqlCommand(); s_cmd.Connection = Connection; } return s_cmd; } }
et là j'obtiens le message d'erreur suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 SqlCommand cmd = DB.Command; //ma méthode static cmd.CommandText = "SELECT ............"; reader = cmd.ExecuteReader();
There is already an open DataReader associated with this Command which must be closed first.
ma question est comment limiter l'accès à ma méthode à un seul accès à la fois.
merci d'avance.
Partager