[BD access] Essai de code
Bonjour, je dispose du code suivant :
Code:
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
| void GamePanel::saveGame(int grid, int width, int boardColor, int p1tokenColor, int p2tokenColor, int difficulty)
{
try
{
strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
strConnection +=" Data Source=connect4.mdb";
connection = gcnew OleDbConnection(strConnection);
connection->Open();
OleInsert = gcnew OleDbCommand( "grid=" + grid +
"width=" + width +
"boardColor=" + boardColor +
"p1tokenColor=" + p1tokenColor +
"p2tokenColor=" + p2tokenColor +
"difficulty=" + difficulty +
";", connection
);
int n = OleInsert->ExecuteNonQuery();
connection->Close();
}
catch (System::Exception ^e)
{
System::Console::WriteLine(e);
}
} |
dans le header correspondant, j'ai déclaré :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
using namespace System;
using namespace System::Data;
using namespace System::Data::OleDb;
...
...
private:
String ^strConnection,^strCmd;
OleDbConnection ^connection;
OleDbCommand ^Olecmd,^OleInsert;
OleDbDataReader ^dr; |
En gros, j'aimerais sauvegarder les différentes int passés en argument à ma fonction saveGame dans ma BD access, mais lors de l'éxécution, j'ai l'erreur suivante :
Citation:
\GamePanel.cpp(135) : error C3624: 'System::Transactions::Transaction': use of this type requires a reference to assembly 'System.Transactions'
while importing type 'System::Data::Common::DbConnection ' from assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
while importing type 'System::Data::OleDb::OleDbConnection ' from assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
.\GamePanel.cpp(135) : warning C4679: 'System::Data::Common::DbConnection::EnlistTransaction' : could not import member
Où est mon erreur ? Dois-je créer manuellement ma base de données Access avant d'éxécuter le code ?
Merci d'avance :)