Salut,

je veux inserer des données dans une BD oracle 9i, j'ai utilisé ce code:

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
 private void button1_Click(object sender, EventArgs e)
        {
 
 
            System.Data.OracleClient.OracleConnection OraCon = new OracleConnection();
            string connexionstring = "data source=ds;user=sys;password=psw;";
            OraCon.ConnectionString = connexionstring;
            OraCon.Open();
            OracleTransaction myOracleTransaction = OraCon.BeginTransaction();
            OracleCommand myOracleCommand = OraCon.CreateCommand();
            myOracleCommand.CommandText ="INSERT INTO inscription (" + "  nom, prenom, activité, fonction, société,département, service, site_web, tel, fax, adr, codePos, ville, pays, connaissance_logivar, besoins, " +  ") VALUES ('"+txtnom.Text.ToString()+"','"+txtprn.Text.ToString()+"','"+activité.Text.ToString()+"','"+fct.Text.ToString()+"', '"+txtsocieté.Text.ToString()+"','"+txtdep.Text.ToString()+"','"+txtservice.Text.ToString()+"','"+txtweb.Text.ToString()+"','"+txttel.Text+"','"+txtfax.Text+"','"+txtadr.Text.ToString()+"','"+txtcodpostal.Text+"','"+txtville.Text.ToString()+"','"+txtpays.Text.ToString()+"','"+comboconnaiLogivar.Text.ToString()+"','"+richTxtbesoin.Text.ToString()+"')";   //'" + a +"'
 
            myOracleCommand.ExecuteNonQuery();
 
            myOracleTransaction.Commit();
            OraCon.Close();
 
        }
Mais l'exception suivante apparait au niveau de: myOracleCommand.ExecuteNonQuery();

Et voici l'exception: execute requires the command object to have a transaction object when the connection abject assigned to the command is in a pending local transaction. The transaction property of the command has not been initialized.

Qu'est ce qui faux dans ces quelques lignes de code?