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 30 31 32 33 34 35
|
string MyConString = "SERVER=localhost;" + "DATABASE=nom.de.base;" + "UID=root;" + "PASSWORD=;";
Private void btt_test_click (object sender, EventArgs e)
{
MySqlConnection mySqlCnx = new MySqlConnection (MyConString);
MySqlCommand mySqlcommand = new MySqlCommand ();
MySqlDataReader mysqldr;
try
{
mySqlCnx.Open();
mySqlCommand.Connection = mySqlCnx;
mySqlCommand.CommandType = commandType.Text;
mySqlCommand.CommandText = "SELECT (id_poste) AS Poste FROM postesource";
mySqldr = mySqlcommand.ExecuteReader();
while (mySqldr.Read())
{
MySqlCommand command = mySqlCnx.CreateCommand();
command.CommandText = "INSERT INTO concerner (id_concerner, id_ordre, id_poste) VALUES ('1', '" + mySqldr["Poste"].ToString() + "','2')";
command1.ExecuteNonQuery();
}
catch (MySqlException Ex)
{
MessageBox.Show(Ex.ToString());
}
} |
Partager