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
|
MySQLConnection connection = new MySQLConnection() ;
MySQLDataAdapter adapter = new MySQLDataAdapter();
DataSet ds = new DataSet();
string server, database, loginn, passeword;
server="localhost";
database="abbd";
loginn="abbd";
passeword="00";
connection = new MySQLConnection(new MySQLConnectionString(server, database, loginn, passeword).AsString);
try
{
connection.Open();
if ((TextBox1.Text.Length != 0) && (TextBox2.Text.Length != 0))
{
string command = "insert into abbd (nom,prenom)" + "values ('" + TextBox1.Text + "','" + TextBox2.Text + "')";
adapter.SelectCommand = new MySQLCommand(command, connection);
reader = adapter.InsertCommand.ExecuteReader();
}
connection.Close();
}
catch (MySQLException ex) { }
} |
Partager