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 36 37 38 39 40 41 42 43 44 45
|
Assembly^ MySQLInterface = Assembly::LoadFile("C:\\Users\\Xabi\\source\\repos\\Bdd Benchmark\\data\\MySQL V8\\MySql.Data.dll");
if (MySQLInterface != nullptr)
{
MessageBox::Show("Ca charge le fichier");
if (auto typeConnection = MySQLInterface->GetType("MySql.Data.MySqlClient.MySqlConnection"))
{
MessageBox::Show("Ca trouve bien la classe");
if (Object^ instanceConnection = Activator::CreateInstance(typeConnection))
{
MessageBox::Show("Ca créée l'instance");
if (auto methodMySQLConnection = typeConnection->GetMethod("MySqlConnection")) {
MessageBox::Show("Ca charge la methode MySqlConnection");
try
{
MessageBox::Show(methodMySQLConnection->Invoke(instanceConnection, gcnew array<Object^>(1) {
"SERVER=" + this->adresse +
";DATABASE=" + this->dataBaseName +
";UID=" + this->login +
";PASSWORD=" + this->mdp + ";"
})->ToString());
}
catch (Exception^ e)
{
MessageBox::Show(e->ToString());
}
}
if (auto connectionOpenMethod = typeConnection->GetMethod("Open")) {
MessageBox::Show("Ca charge la methode Open");
try
{
MessageBox::Show(connectionOpenMethod->Invoke(instanceConnection, nullptr)->ToString());
}
catch (Exception^ e)
{
MessageBox::Show(e->ToString());
}
}
}
}
} |
Partager