Page 1 of 1

Displaying Database Fields in a Listview Gadget

Posted: Sun Jan 02, 2011 12:06 am
by tbohon
In the following code

Code: Select all

          While NextDatabaseRow(dbHandle)
            AddGadgetItem(#LVIEW, -1, GetDatabaseString(dbHandle, 0))
          Wend
where the database is defined with three columns: ID (INTEGER, PrimaryKey, Autoincrement), tagline (VARCHAR(50)) and Description (VARCHAR(100))

why do I get a seemingly blank ListviewGadget if the last value above ('0') is set to 1, the field (tagline) that I'm trying to retrieve? I say 'seemingly blank' field because if you hit the 'query' button enough times a vertical scrollbar appears - with nothing showing in the ListviewGadget.

The routine works like it is shown above but it's counter intuitive to me - field '0' should be the ID, field '1' should be the (desired) tagline field and field '2' should be the contents.

It's making me CRAZY ... :shock:

I'm sure there is a logical explanation ... isn't there ... ??? Is it because the first field is an Integer and not a string???

TIA.

Tom

Re: Displaying Database Fields in a Listview Gadget

Posted: Sun Jan 02, 2011 2:30 am
by IdeasVacuum
I don't have a db to hand but try something like this:

Code: Select all

iRowCnt.i = 0

While NextDatabaseRow(dbHandle)

     AddGadgetItem(#LVIEW,-1,StrU(GetDatabaseQuad(dbHandle, 0)))
     SetGadgetItemText(#LVIEW,iRowCnt,GetDatabaseString(dbHandle, 1)),1)
     SetGadgetItemText(#LVIEW,iRowCnt,GetDatabaseString(dbHandle, 2),2)
     iRowCnt = iRowCnt + 1

Wend