yasmine.bennadir
Messages postés14Date d'inscriptionmercredi 31 juillet 2013StatutMembreDernière intervention 3 octobre 2013
-
5 août 2013 à 14:21
yasmine.bennadir
Messages postés14Date d'inscriptionmercredi 31 juillet 2013StatutMembreDernière intervention 3 octobre 2013
-
5 août 2013 à 17:09
Bonjour,
j 'ai besoin de votre aide j'arrive pas à corriger cet erreur (La connexion n'est pas fermée. L'état actuel de la connexion est ouvert.) pouvez vous m'aider??
public void add()
{
DialogResult dr = MessageBox.Show("étes vous sur de vouloir ajouter cette ligne?", "confirmation", MessageBoxButtons.YesNo);
switch (dr)
{
case DialogResult.Yes:
alter_table();
foreach(string key in columns){
foreach (string name in columnsNames) {
// if (key != name)
{MessageBox.Show(name + "!=" + key);
conn.commandString = "ALTER TABLE Table1 ADD "+ key +" Varchar(100)";
conn.load_informations_forUpdating_Ordelete();
Close();
}
}
}
break;
}
public void alter_table()
{
string conStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/Users/yasmineben/Documents/Visual Studio 2010/Projects/ONCFApplication/ONCFApplication/bin/BD-ONCF_QCM.accdb";
OleDbConnection con = new OleDbConnection(conStr);
con.Open();
OleDbCommand cmd = new OleDbCommand("select * from Table1", con);
OleDbDataReader reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly);
DataTable table = reader.GetSchemaTable();
DataColumn nameCol = table.Columns["ColumnName"];
foreach (DataRow row in table.Rows)
{
columnsNames.Add((string)row[nameCol]);
}
con.Close();
}
}