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
|
private void btnOK_Click(object sender, EventArgs e)
{
OleDbConnection cnct;
OleDbCommand cmd;
String stringConnection = "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5; Data Source=|DataDirectory|/dbShelter.sdf;";
try
{
cnct = new OleDbConnection(stringConnection);
cnct.Open();
cmd = new OleDbCommand ("INSERT INTO Customer (Civility, FirstName, Name, AdressL1, AdressL2, "
+ "ZipCode, City, Country, TelHome, TelOffice, TelMobile, Fax, Observations, OriginBooking, TypeOf, "
+ "Appreciation, DateCreated) "
+ "VALUES (" + cbCivility.Text + "," + tbFirstName.Text + "," + tbName.Text + "," + tbAdressL1.Text + ","
+ tbAdressL2.Text + "," + tbZipCode.Text + "," + tbCity.Text + "," + cbCountry.Text + ","
+ tbTelHome.Text + "," + tbTelOffice.Text + "," + tbTelMobile.Text + "," + tbFax.Text + ","
+ tbObservations.Text + "," + cbOriginBooking.Text + "," + cbTypeOf + "," + cbAppreciation.Text + ","
+ dtpDateCreated.Value + ")", cnct);
cmd.ExecuteNonQuery();
cnct.Close();
}
catch(Exception x)
{
MessageBox.Show(this, x.Message, "Erreur Connexion à la base", MessageBoxButtons.OK, MessageBoxIcon.Error);
Close();
}
} |
Partager