can't insert arecord in a oracle database using C#
- by Gya
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 adaugat î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);
}
}