Sunteți pe pagina 1din 3

private void button1_Click(object sender, EventArgs e)

{
try
{
string sirconectare = "Provider=Microsoft.ACE.OLEDB.12.0;Data So
urce=D:\\ExameneDB.accdb;Persist Security Info=False;";
OleDbConnection conexiune;
conexiune = new OleDbConnection();
conexiune.ConnectionString = sirconectare;
conexiune.Open();
MessageBox.Show("M-am conectat");
OleDbCommand comanda;
comanda = new OleDbCommand();
comanda.CommandText = "UPDATE Examene SET denExamen= @denExamn W
HERE denExamen= @denExamv";
comanda.CommandText = "UPDATE Examene SET codExamen=@codExamn WH
ERE codExamen=codExamv";
comanda.Parameters.AddWithValue("codExamv", txtcodExamenvechi.Te
xt);
comanda.Parameters.AddWithValue("denExamv", txtdenExamenvechi.Te
xt);
comanda.Parameters.AddWithValue("codExamn", txtcodExamennou.Text
);
comanda.Parameters.AddWithValue("denExamn", txtdenExamennou.Text
);
comanda.Connection = conexiune;
comanda.ExecuteNonQuery();
MessageBox.Show("Am adaugat o noua masina in BD");
conexiune.Close();
}
catch (Exception eroare)
{
MessageBox.Show("A aparut o eroare" + eroare.Message.ToString())
;

try
{
string sirconectare = "Provider=Microsoft.ACE.OLEDB.12.0;Data So
urce=D:\\ExameneDB.accdb;Persist Security Info=False;";
OleDbConnection conexiune;
conexiune = new OleDbConnection();
conexiune.ConnectionString = sirconectare;
conexiune.Open();
MessageBox.Show("M-am conectat");
OleDbCommand comanda;
comanda = new OleDbCommand();
comanda.CommandText="SELECT numarStudentiExaminati FROM Examene W
HERE denExamen=@denExam";
comanda.Parameters.AddWithValue("denExam", txtdenExamen.Text);

comanda.Connection = conexiune;
comanda.ExecuteNonQuery();
MessageBox.Show("La examenul"+denExamen+"sunt inscrisi"+numarStu
dentiExaminati+"de studenti");
conexiune.Close();
}
catch (Exception eroare)
{
MessageBox.Show("A aparut o eroare" + eroare.Message.ToString())
;

try
{
string sirconectare = "Provider=Microsoft.ACE.OLEDB.12.0;Data So
urce=D:\\ExameneDB.accdb;Persist Security Info=False;";
OleDbConnection conexiune;
conexiune = new OleDbConnection();
conexiune.ConnectionString = sirconectare;
conexiune.Open();
MessageBox.Show("M-am conectat");
OleDbCommand comanda;
comanda = new OleDbCommand();
comanda.CommandText="SELECT denMasina FROM Masini WHERE Marca=@de
nMarca";
comanda.Parameters.AddWithValue("denMarca",txtdenMarca.Text);
comanda.Connection=conexiune;
comanda.ExecuteNonQuery();
MessageBox.Show("
conexiune.Close();
}
catch (Exception eroare)
{
MessageBox.Show("A aparut o eroare" + eroare.Message.ToString())
;

private void button1_Click(object sender, EventArgs e)


{
try
{
string sirconectare = "Provider=Microsoft.ACE.OLEDB.12.0;DataSou
rce=D:\\ExameneDB.accdb;Persist Security Info=False;";
OleDbConnection conexiune;
conexiune = new OleDbConnection();
conexiune.ConnectionString = sirconectare;
conexiune.Open();
MessageBox.Show("M-am conectat");
OleDbCommand comanda;
comanda = new OleDbCommand();
OleDbDataReader cititor;
DataSet dsDate;
DataTable tblExamene;
comanda.CommandText = "SELECT codExamen,denExamen,numeProfesor,n
umarStudentiExaminati FROM Examene WHERE denExamen=@denEx";
comanda.Parameters.AddWithValue("denEx", txtdenExam.Text);
comanda.Connection = conexiune;
cititor = comanda.ExecuteReader();
dsDate = new DataSet();
tblExamene = new DataTable("EXAMENE");
tblExamene.Load(cititor);
dsDate.Tables.Add(tblExamene);
string denEx;
int nrSt;
MessageBox.Show("Au fost citite" + dsDate.Tables["EXAMENE"].Rows
.Count + "inregistrari");
for (int i = 0; i < dsDate.Tables["EXAMENE"].Rows.Count; i++)
{
denEx = dsDate.Tables["EXAMENE"].Rows[i].ItemArray[1].ToStri
ng();
nrSt = int.Parse(dsDate.Tables["EXAMENE"].Rows[i].ItemArray[
3].ToString());
MessageBox.Show("La examenul" + denEx + "participa" + nrSt +
"studenti");
}
conexiune.Close();
}
catch (Exception eroare)
{
MessageBox.Show(" A aparut o eroare" + eroare.Message);
}
}
}
}