Here are the bits of code... apologies, I am sure they will not be indented
properly...
This is the code that populates the structure, and it is only called when I
move from the main form, not when I return...
// First execute the query
// the query is stored in a global variable, built somewhere else
rc = SQLExecDirect(hstmt, query, SQL_NTS);
if (SQL_SUCCESS != rc) {
FrmCustomAlert(DBErrorAlert,"Error", "Executing Query", " ");
ReportSQLError(hstmt);
return;
}
// Then bind the columns... this for all the columns in the query
rc = SQLBindCol(hstmt,1,SQL_C_CHAR,tname,101,&len1);
if (SQL_SUCCESS != rc) {
FrmCustomAlert(DBErrorAlert,"Error", "Binding Name Column", " ");
ReportSQLError(hstmt);
return;
}
// Then I fetch the data and populate the structure...
numRecords = 0;
while (1) {
if ( numRecords < APP_MAX_ROW ) {
rc = SQLFetch(hstmt);
if ((rc != SQL_SUCCESS) && (rc != SQL_SUCCESS_WITH_INFO)){
if (rc == SQL_NO_DATA_FOUND) {
return;
} else {
FrmCustomAlert(DBErrorAlert,"Error", "Fetching Data", " ");
ReportSQLError(hstmt);
break;
}
}
for ( i=0; i<len1; i++ )
records.catalogno[numRecords][i] = tcat[i];
records.catalogno[numRecords][len1] = 0;
records.number[numRecords] = tempno;
for ( i=0; i<len2; i++ )
records.title[numRecords][i] = ttitle[i];
records.title[numRecords][len2] = 0;
} else {
StrIToA(t,APP_MAX_ROW);
FrmCustomAlert(DBInfoAlert,"Maximum number of rows reached. Only ", t,
" rows displayed");
break;
}
numRecords++;
}
The piece List Draw function uses the structure... as follows:
static void albumsListDraw(Int16 id, RectangleType *bounds, Char **data)
{
Char *itemText;
itemText = records.title[id];
if (itemText) {
WinDrawChars(itemText,StrLen(itemText),bounds->topLeft.x,bounds->topLeft.y);
}
return;
} // end albumsListDraw()
Thanks,
Carlos
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/