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
|
foreach (string ios in Name_IOS)
{
// Requete parametrée
string Requete = "INSERT INTO ios_citadis(nom_ios,describe_ios,comment_ios,function_ios) VALUES (?nom_ios,?describe_ios,?comment_ios,?function_ios);";
// On associe cette requête à la propriété SelectCommand du MySqlDataAdapter
MyAdapter.SelectCommand = new MySqlCommand(Requete, Connection);
//Création et déclaration des paramètres
MySqlParameter myparamnom = new MySqlParameter("?nom_ios", MySqlDbType.Char, 30);
MySqlParameter myparamdescribe = new MySqlParameter("?describe_ios", MySqlDbType.Char, 255);
MySqlParameter myparamcomment = new MySqlParameter("?comment_ios", MySqlDbType.Char, 255);
MySqlParameter myparamfunction = new MySqlParameter("?function_ios", MySqlDbType.Char, 255);
//Attribution des valeurs aux paramètres
myparamnom.Value = ios.ToString();
// Je récupère l'indice de la variable
int indOfVar = Name_IOS.IndexOf(ios, 0);
myparamdescribe.Value = describ_IOS.ElementAt(indOfVar).ToString().Replace("é","e");
myparamcomment.Value = comment_IOS.ElementAt(indOfVar).ToString().Replace("é","e");
myparamfunction.Value = function_IOS.ElementAt(indOfVar).ToString().Replace("é","e");
MyAdapter.SelectCommand.Parameters.Add(myparamnom);
MyAdapter.SelectCommand.Parameters.Add(myparamdescribe);
MyAdapter.SelectCommand.Parameters.Add(myparamcomment);
MyAdapter.SelectCommand.Parameters.Add(myparamfunction);
MyAdapter.SelectCommand.ExecuteNonQuery();
} |
Partager