try
{
int val4 = Convert.ToInt32(tbGrupa.Text);
string MyConString = "Data Source=**;User ID=******;Password=*****";
OracleConnection conexiune = new OracleConnection(MyConString);
OracleCommand comanda = new OracleCommand();
comanda.Connection = conexiune;
conexiune.Open();
comanda.Transaction = conexiune.BeginTransaction();
int id_stud = Convert.ToInt16(tbCodStud.Text);
string nume = tbNume.Text;
string prenume = tbPrenume.Text;
string initiala_tatalui = tbInitiala.Text;
string email = tbEmail.Text;
string facultate = tbFac.Text;
int grupa = Convert.ToInt16(tbGrupa.Text);
string serie = tbSeria.Text;
string forma_de_inv = tbFormaInvatamant.Text;
DateTime data_acceptare_coordonare = dateTimePicker1.Value;
DateTime data_sustinere_licenta = dateTimePicker2.Value;
string sustinere = tbSustinereLicenta.Text;
string parola_acces = tbParola.Text;
try
{
comanda.Parameters.AddWithValue("id_stud", id_stud);
comanda.Parameters.AddWithValue("nume", nume);
comanda.Parameters.AddWithValue("prenume", prenume);
comanda.Parameters.AddWithValue("initiala_tatalui", initiala_tatalui);
comanda.Parameters.AddWithValue("facultate", facultate);
comanda.Parameters.AddWithValue("email", email);
comanda.Parameters.AddWithValue("seria", serie);
comanda.Parameters.AddWithValue("grupa", grupa);
comanda.Parameters.AddWithValue("forma_de_inv", forma_de_inv);
comanda.Parameters.AddWithValue("data_acceptare_coordonare", data_acceptare_coordonare);
comanda.Parameters.AddWithValue("data_sustinere_licenta", data_sustinere_licenta);
comanda.Parameters.AddWithValue("sustinere_licenta", sustinere);
comanda.Parameters.AddWithValue("parola_acces", parola_acces);
comanda.Transaction.Commit();
MessageBox.Show("Studentul " + tbNume.Text + " " + tbPrenume.Text + " a fost adăugat în baza de date!");
}
catch (Exception er)
{
comanda.Transaction.Rollback();
MessageBox.Show("ER1.1:" + er.Message);
MessageBox.Show("ER1.2:" + er.StackTrace);
}
finally
{
conexiune.Close();
}
}
catch (Exception ex)
{
MessageBox.Show("ER2.1:"+ex.Message);
MessageBox.Show("ER2.2:"+ex.StackTrace);
}
Répondre
Il ne semble pas y avoir d'instruction d'insertion. Je pense que c'est ce que le problème est. Vous auriez besoin quelque chose comme:
using (OracleConnection connection = new OracleConnection(connectionString))
{
OracleCommand command = new OracleCommand(myExecuteQuery, connection);
command.Connection.Open();
command.ExecuteNonQuery();
}
Il y a une COMMIT, ce que vous allez engager s'il n'y a pas de déclaration d'insertion avant?
donc..j'ai manqué l'instruction d'insertion ... mais il fait la même chose: la seule chose qu'il me montre est que l'étudiant XY a été inséré dans le db mais il ne l'insère pas réellement .. C'est ce que j'ai raté mais toujours non-fonctionnel: comanda.CommandText = "INSERT INTO student VALUES (?,?,?,?,?,?,?,?,? ,?,?,?,?) "; comanda.Parameters.AddWithValue ("id_stud", id_stud); comanda.Parameters.AddWithValue ("nume", nume); comanda.Parameters.AddWithValue ("prenume", prenume); [...] [en passant, c'est en roumain] – Gya
Un énorme morceau de code, aucun message d'erreur, aucune indication de ce qui ne va pas ou comment vous avez essayé de le réparer, pas vraiment de question même ... vraiment? – Donnie
s'il vous plaît, appelez les identifiants en anglais. c'est le langage de l'informatique de facto. – Andrey
Le code est toujours lisible même avec des identifiants non-anglais. Quel est le problème/question? – Freiheit