R: ODBC information not retrieved after query
Baldassarre Cesarano
baldassarre.cesarano at eunics.it
Tue Jun 26 04:32:59 PDT 2007
I think you have omitted
ScreenTabe->GetNext();
=
Baldo
_____ =
Da: Elliott Rezny [mailto:erezny at gmail.com] =
Inviato: marted=EC 26 giugno 2007 9.18
A: wx-users at lists.wxwidgets.org
Oggetto: ODBC information not retrieved after query
I have followed the database classes overview section of the manual to the
best of my ability,and I am having =
problems getting the column information into my variables from my table
query.
I know that the query returned the single entry I was looking for because I
check the number of rows returned =
after I run the query and it shows 1. However, my variables (Index, Title[],
Value[]) are not changed at all.
I am guessing that I am not setting the pointer to my variables correctly,
but I cannot find any clue that I'm =
doing it wrong from the example in the manual.
Thank you for reading my e-mail. any help is appreciated.
Elliott Rezny
for reference, I'm using:
wxwidgets V 2.8.4 -unicode debug build
MSVC 2005 express version =
MS-SQL 2005 express version
the relevant code (Copied and pasted from different functions so that only
relevant code is shown)is:
DbConnectInf =3D new wxDbConnectInf(NULL, _T("ReznyPOS"), _T("elliott")); =
if (!DbConnectInf || !DbConnectInf->GetHenv())
{
HandleError(_T("DB ENV ERROR: Cannot allocate ODBC env handle"));
}
//get the connection
Db =3D wxDbGetConnection(DbConnectInf);
if (!Db) =
{
HandleError(_T("CONNECTION ERROR: - Cannot get DB connection"));
}
wxDbTable *ScreenTable;
ScreenTable =3D new wxDbTable(Db, _T("ScreenSetup"),41);
//my variables to hold colum information =
wxChar Title[20][34]; //0-9 Items, 10-19 Menus
wxChar Value[20][34];
signed long Index;
//set the column defaults
ScreenTable->SetColDefs(0, _T("ID "), DB_DATA_TYPE_INTEGER, &Index,
SQL_C_LONG, sizeof(Index), true);
ScreenTable->SetColDefs(1, _T("\"Button Name 1\" "), DB_DATA_TYPE_VARCHAR,
Title[0],
SQL_C_WXCHAR, sizeof(Title[0]), false); =
ScreenTable->SetColDefs(2, _T("\"Button Value 1\" "), DB_DATA_TYPE_VARCHAR,
Value[0],
SQL_C_WXCHAR, sizeof(Value[0]), false);
//continue setting colDefs until all the names and values are defined =
//Create the table
if (!ScreenTable->CreateTable(true))
{
HandleError(_T("ScreenSetup Table Creation Error:"),
ScreenTable->GetDb());
} =
//Open the table
if (!ScreenTable->Open()){ =
HandleError(wxT("SCREEN-TABLE OPEN ERROR: "), ScreenTable->GetDb());
}
//set query data
ScreenTable->SetWhereClause(_T("ID =3D 1"));
ScreenTable->SetOrderByClause(_T("")); =
ScreenTable->SetFromClause(_T(""));
//run the query
if (!ScreenTable->Query()){
HandleError(_T("SCREENTABLE INITIAL QUERY ERROR:"),
ScreenTable->GetDb());
}
//set a breakpoint so that I can tell if the query worked =
long temp =3D ScreenTable->Count();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wx-users/attachments/20070626/a6b=
624fe/attachment.htm
More information about the wx-users
mailing list