Hi, I already asked a question a few days ago (thanks for your help again upCase), but I already have a question again.
I wrote a wxWindows-Program and want to use a Database-Table to save and load some settings. The follow code I wrote so far:
wxDbConnectInf *dci = new wxDbConnectInf(NULL, "DSN", "User", "PW");
if (!dci || !dci->GetHenv())
{
wxLogMessage("Error");
return;
}
wxDb *dab = wxDbGetConnection(dci);
wxDbTable *tbl = new wxDbTable(dab, "Table_Name", 4, "", false, "");
wxChar Field1[51];
wxChar Field2[16];
tbl->SetColDefs(1, "Field1", DB_DATA_TYPE_VARCHAR, Field1, SQL_C_CHAR, sizeof(Field1));
tbl->SetColDefs(2, "Field2", DB_DATA_TYPE_VARCHAR, Field2, SQL_C_CHAR, siezof(Field2));
tbl->Open();
tbl->SetWhereClause("");
tbl->SetOrderByClause("");
tbl->SetFromClause("");
if (!tbl->Query())
{
wxMessage("Error");
return;
}
while (tbl->GetNext())
{
}
delete tbl;
if (dab)
{
wxDbFreeConnection(dab);
dab = NULL;
}
wxDbCloseConnections();
delete dci;
The Problem is that he shows an error when I send the Query. The function returns with false.
I would really appreciate any help. Thanks in advance.
|