ComboBoxGadget + Database Help Please

Everything else that doesn't fall into one of the other PB categories.
ShDancer
User
User
Posts: 51
Joined: Sat Apr 26, 2003 5:49 am

ComboBoxGadget + Database Help Please

Post by ShDancer »

Hello, there.
I wonder if one of you can help me.

For example i have a database that has a several tables in side :roll: (what's new), so here's the example

RegularityID(Number), Description(Varchar)
2, Week
4, Month
8, Year

So when i add these to a combo box gadget like this

Code: Select all

        Query$ = "SELECT RegularityID, Description FROM Regularity ORDER BY RegularityID"
        If DatabaseQuery(Query$)
          While NextDatabaseRow()
            ID.l = Val(GetDatabaseString(0)) 
            Value.s = GetDatabaseString(1)
            AddGadgetItem(#Combo_1, -1, Value)
            Debug Str(ID) + " | " + Value
          Wend
        Else
          AddGadgetItem(#Combo_1, -1, "No Results found")
        EndIf
      Else
        Debug "DB Error: " + DatabaseError()
      EndIf
I only get the names and position but not the ID that is on the
database. So whe i read the contents of that it gives me the
text (its correct), but i can't use the ID for nothing.

if i use

Code: Select all

            AddGadgetItem(#Combo_1, ID, Value) 
It doesn't show nothing at all.

Is there a way to put the ID in the Combo Box, so i can get the ID
instead of the Text. It's very useful so when i have to insert in the
data in the database i will insert only the ID instead of the Text.

If i only get the text i'll have to make another SELECT to the
Database to know what Text corresponds to the Specific ID.

Is there any way to accomplish this???

Thanks in advance.
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

Hi ShDancer,
have you tried this : :idea:

Code: Select all

ID.l=GetDatabaseLong(0)
Post Reply