1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
try
{
// Chaîne de connexion
string connectString = "Data Source="+repertoire+"\\DataBase\\database.mdb;User Id=admin;Password=;" ;
// Objet connection
SqlConnection connection = new SqlConnection(connectString);
// Ouverture
connection.Open();
// Objet Command
SqlCommand command = new SqlCommand("INSERT INTO Table_Periodes (Nom_Periodes,Annee,Duree) VALUES ('coucou','1900',3)", connection);
// Execution
int affectedrows = command.ExecuteNonQuery();
Console.WriteLine("Nombre de lignes affectées {0}", affectedrows);
// Fermeture
connection.Close();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
} |