PB Récupération de nom de tables

PI08 Messages postés 1 Date d'inscription mardi 31 mars 2009 Statut Membre Dernière intervention 28 janvier 2010 - 28 janv. 2010 à 13:27
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019 - 28 janv. 2010 à 15:55
Bonjour,
Je dois réaliser une interface (MFC) afin d'afficher des informations sur une base de données. Malheureusement je n'arrive tout simplement pas à récupérer le noms des tables. Voici le code que j'utilise :

struct
{
SQLINTEGER   ind;
SQLCHAR      s[130];
} tableName, tableType;

SQLHSTMT hstmtTABLES;

SQLAllocHandle( SQL_HANDLE_STMT, mDatabase.m_hdbc, &hstmtTABLES );
SQLTables(hstmtTABLES,NULL,0,(unsigned char*)"CINE",SQL_NTS,(unsigned char*)"%",SQL_NTS,NULL,0);

SQLBindCol(hstmtTABLES,3,SQL_C_CHAR,(SQLPOINTER) tableName.s,130,&tableName.ind);
SQLBindCol(hstmtTABLES,4,SQL_C_CHAR,(SQLPOINTER) tableType.s,130,&tableType.ind);

int nRow = 0; 

while (SQLFetch(hstmtTABLES) SQL_SUCCESS/* || rc SQL_SUCCESS_WITH_INFO*/)
{
tableList.InsertItem(nRow,(char *)tableName.s);
tableList.SetItem(nRow,1,LVIF_TEXT,(char *)tableType.s, -1, 0, 0, 0);

nRow++;
}

SQLFreeHandle( SQL_HANDLE_STMT,hstmtTABLES);


tableList étant un "List Control". Après exécution, la liste reste vide et nRow = 0, ce qui suppose que le problème vient du "SQLFetch()".
Est ce quelqu'un aurait une petite idée?...

Merci!

1 réponse

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
28 janv. 2010 à 15:55
controle d'erreur EFFICACE: if(retcd & 0xFFFE) ERREUR

retcd = SQLTables(hstmt, 0, 0, 0, 0, 0, SQL_NTS, 0, 0);
if(retcd & 0xFFFE) OnSortDici;

ciao...
BruNews, MVP VC++
0
Rejoignez-nous