public void insert_data()
{
string source = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\\sc.mdb";
string command1 = string.Format("select count(*) from Fourn where
NoFourn = {0}", Int64.Parse(textBox1.Text));
string command2 = string.Format("insert into Fourn
(NoFourn,NomFourn,TelFourn) values({0},'{1}',{2})",
Int64.Parse(textBox1.Text), textBox2.Text,
Int64.Parse(textBox3.Text));
string command3 = string.Format("update from Fourn set
NomFourn='Michel' where NoFourn=15");
OleDbCommand iCommand = new OleDbCommand();
OleDbConnection iConnection = new OleDbConnection(source);
{
iConnection.Open();
iCommand.Connection = iConnection;
iCommand.CommandText=command1;
OleDbDataReader iReader1;
iReader1 = iCommand.ExecuteReader();
iReader1.Read();
{
if(iReader1.GetInt32(0) != 0)
{
iReader1.Close();
iCommand.CommandText=command3;
MessageBox.Show("Deja Existant");
iReader1.Close();
iConnection.Close();
}
else
{
iReader1.Close();
iCommand.CommandText=command2;
textBox1.Text="";
textBox2.Text="Cfait";
textBox3.Text="";
iConnection.Close();
}
}
}