Bonjour, celà fait bientôt une semaine que je butte sur un problème.
Je n'arrive pas à utiliser une base sous PostGreSQL en utilisant wxDb.
J'ai repris l'exemple donnée dans wxWidgets :
// -----------------------------------------------------------------------
// DEFINE THE CONNECTION HANDLE FOR THE DATABASE
// -----------------------------------------------------------------------
DbConnectInf = new wxDbConnectInf(NULL,
wxT("nom"),
wxT("user"),
wxT("pass"));
// Error checking....
if (!DbConnectInf || !DbConnectInf->GetHenv())
{
return HandleError(wxT("DB ENV ERROR: Cannot allocate ODBC env handle"));
}
// -----------------------------------------------------------------------
// GET A DATABASE CONNECTION
// -----------------------------------------------------------------------
db = wxDbGetConnection(DbConnectInf);
if (!db)
{
return HandleError(wxT("CONNECTION ERROR - Cannot get DB connection"));
}
// -----------------------------------------------------------------------
// DEFINE THE TABLE, AND THE COLUMNS THAT WILL BE ACCESSED
// -----------------------------------------------------------------------
table = new wxDbTable(db, "nom_de_table", 2, wxT(""),
!wxDB_QUERY_ONLY, wxT(""));
//
// Bind the columns that you wish to retrieve. Note that there must be
// 'numTableColumns' calls to SetColDefs(), to match the wxDbTable def
//
// Not all columns need to be bound, only columns whose values are to be
// returned back to the client.
//
table->SetColDefs(0, wxT("Nom"), DB_DATA_TYPE_VARCHAR, FirstName,
SQL_C_WXCHAR, sizeof(FirstName), true, true);
table->SetColDefs(1, wxT("Unite"), DB_DATA_TYPE_VARCHAR, LastName,
SQL_C_WXCHAR, sizeof(LastName), true, true);
// -----------------------------------------------------------------------
// CREATE (or RECREATE) THE TABLE IN THE DATABASE
// -----------------------------------------------------------------------
if (!table->CreateTable(true)) //NOTE: No CommitTrans is required
{
return HandleError(wxT("TABLE CREATION ERROR: "), table->GetDb());
}
// -----------------------------------------------------------------------
// OPEN THE TABLE FOR ACCESS
// -----------------------------------------------------------------------
if (!table->Open())
{
return HandleError(wxT("TABLE OPEN ERROR: "), table->GetDb());
}
// -----------------------------------------------------------------------
// INSERT A NEW ROW INTO THE TABLE
// -----------------------------------------------------------------------
wxStrcpy(FirstName, wxT("exemple"));
wxStrcpy(LastName, wxT("kg*m²"));
if (!table->Insert())
{
return HandleError(wxT("INSERTION ERROR: "), table->GetDb());
}
// Must commit the insert to write the data to the DB
table->GetDb()->CommitTrans();
J'ai donc des erreurs quand j'insère une ligne, quand je crée une table, quand, je récupère.
J'ai vérifier les droit, l'existance de la table. C'est normalement bon.
j'ai une erreur sqlstate = S1000
Error while executing the query. Relation "nom_de_table" does not exist.
Error : current transaction is arbored, commands ignored until end of transaction bloc
Je ne sais vraiment pas quoi faire, c'est très étrange, j'ai accès à la base de donnée, je peux voir les nom des tables. Mais je ne peux faire aucune modification. Meme pour creer un table. Auriez vous une idée.
Serais ce les type qui ne sont pas bon ? Je vois qu'on a char(1024 dans la base), en débugue je vois bpchar.
Un grand merci à tous ! Vraiment du fond du coeur.