Bonjour;
je suis entrain de developper une appli ,et dans une methode j'ai 3 requetes a ecrire, dans un premier temps j'ai utilisé une transaction ,je me retrouve directement dans le catch , ensuite j'ai utilisé sqldataReader (le meme pour les 3 requetes) et la gros mystere :
si je laisse les 3 requetes je vais directement dans le catch et si je met la premiere requete en comentaire ; pas de souci la deuxième s'execute correctement et non la troisieme qui me renvoi dans le catch , si j'inverse (en commentaire la deuxieme ), la premiere s'execute correctement et non la troisieme:
voici le code ,peut que qlqu'un saurait me debloquer :
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
 SqlConnection connection = DAOTools.getConnection();
                                SqlCommand command1 = new SqlCommand();
                               SqlCommand command2 = new SqlCommand();
                               SqlCommand command3 = new SqlCommand();
                               command1.Connection = connection;
                               command2.Connection = connection;
                               command3.Connection = connection;
 
 
               (name,table_code,hd_offer_oid) values ('t2" + offre.name + "_" + "AnyTimeServicePrice','t2AnyTimeServicePrice',1)";
                //command.CommandText = request1;
 
                CreateOfferResult result = new CreateOfferResult();
 
               try
                {
 string req1 = "insert into offer (code, hd_offer_code,is_masterisable) values ("+"'"+offre.name+"'"+",'of"+offre.name+"',1)";
                    if (log.IsDebugEnabled) log.Debug(req1);
                    command1.CommandText = req1;
 
 
                    SqlDataReader reader = command1.ExecuteReader();
                    while (reader.Read())
                    {
                    }
                    string req2 = " insert into hd_offer (code,is_active) values ('of"+offre.name+"',0)";
                    if (log.IsDebugEnabled) log.Debug(req2);
                    command2.CommandText = req2;
 
                      reader = command2.ExecuteReader();
                    while (reader.Read())
                    {
                    }
 
                     string req3 = "insert into tt_instance (name,table_code,hd_offer_oid) values"+ 
                                           ("select * from"+
                                          "(select SUBSTRING(tcf.TABLE_NAME,1,2)"+offre.name+"_"+
                                           "SUBSTRING(tcf.TABLE_NAME,3,LEN(tcf.TABLE_NAME)) as name,"+ 
                                           "tcf.TABLE_NAME as table_code"+
                                           "from Charge_table ct"+
                                           "join Charge_to_Table_code cttc on cttc.charge_oid=ct.oid"+
                                           "join  Table_code_factory tcf on tcf.oid=cttc.TABLE_CODE_OID"+
                                           "where ct.NAME in ('dialin'))list_table,"+  
                                           "(select oid from hd_offer where code=offre.name)"+"list_offer_oid");
 
                  if (log.IsDebugEnabled) log.Debug(req3);
                  command3.CommandText = req3;
 
                                     reader = command3.ExecuteReader();
                    while (reader.Read())
                    {
                    }
 
                                   result.Status = Const.RESULT_OK;
 
 
                                                                                                                                             }
                catch (Exception e)
                {
                                       result.Status = Const.RESULT_ERROR;
 
                                       log.Error(String.Format(ErrorMessages.DB_READ_ERROR + ": {0}, {1}", e.Message, e.StackTrace));
                    throw new DBConnectionError(ErrorMessages.DB_READ_ERROR + ": " + e.Message);
                }
                finally
                {
                    connection.Close();
                }
Merci d'avance