Displaying Database Fields in a Listview Gadget

Just starting out? Need help? Post your questions and find answers here.
tbohon
User
User
Posts: 42
Joined: Sat Nov 22, 2008 4:22 am
Location: Olympia, WA USA

Displaying Database Fields in a Listview Gadget

Post 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
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Displaying Database Fields in a Listview Gadget

Post 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
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply