Page 1 of 1

PostPosted: Sat Jun 21, 2003 8:30 am
by fookyean
I has a function to load all the record from db, but the read() only read 1 record only. Anybody can help ?

void loadStockListData(){
int nRec;
StringList slStk_List;
Database db;
DBRecord rec, jrec;

StockData* tempentry;

tempentry = new StockData[10];

// open the database
if (, false)) {

db.getrec(nRec, jrec, false);

// Can not get more than one record, why ?[0], typeof(StockData), 10);
for (nRec=0;nRec<10;nRec++)
slStk_List.add( tempentry[nRec].code ) ;

} // db open



PostPosted: Sat Jun 21, 2003 4:37 pm
by rogernc
The way you have that written it will only read 1 record. You would have to do the getrec and read within your for loop so it will cycle through each record and add them to your stringlist.
Hope this helps.

Roger C

PostPosted: Tue Apr 24, 2007 12:46 pm
by kda406
I am trying to display lines from log files that have been downloaded from a micro controller in the same way Fookyean was attempting to here. I need to get 12 records from the database, and show them in a stringlist or similar. I don't see any other references to this in the OrbForms help, or on this forum.

<b>Is there a way to get multiple (like 12) records from a database at one time without repeated Database.getrec() commands?</b>

Also, why in the world does require a count parameter and advance if it will only ever give you one record in return??? This seems wrong. What are we missing here?

Many thanks,

PostPosted: Wed May 30, 2007 12:19 pm
by mlambrigger
Have you try to define not a DBRecord object but an array of DBRecord an pass it to the getrec() function with more than 1 as number parameters

Marc Lambrigger

PostPosted: Thu Jun 28, 2007 2:28 am
by dewey
read() takes a count so that you can read multiple pieces of data from the same record. For example, if your record contains 10 ints, you could read them all by calling read(intArray, typeof(int), 10).