Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Help for a Listbox program using DB

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-11-2009, 12:31 PM
Junior Member
 
Join Date: Oct 2009
Location: India
Posts: 11
Default Help for a Listbox program using DB

Dear Friends,

I need to do a ListBox program.
I have a table called Country.
Fields are country_code and country_name.
I need to use this dropdownbox in a form Customer. Where I need to select a Country from a list box and it will be saved into the Customer table along with other fields.

I need to insert only country_code into customer table and no need of country_name. But in the form, in drop down box (Listbox) I need to show the county_name.

So How I can do this program ?.

My current program is given below

AddListBox ("frmCustomer","ListBoxCountry", 200, 160, 100, 25)
Command.CommandText = "SELECT * FROM t01_country"
Reader.Value = Command.ExecuteReader
Do While Reader.ReadNextRow = True
ListBoxCountry.Add(Reader.GetValue(1))
Loop
Reader.Close


If I use GetValue(0) I will get country_code
If I use GetValue(1) I will get country_name

How I can both, ie
In client side, dropdownbox shows the country_name
but when I click on a Save button, I need the value of country_code.

I am new to Basic4ppc, I think you got the idea,
In HTML.
It is like
<select name='country'>
<option value='IND'>India</option>
<option value='ESP'>Spain</option>
<option value='JPN'>Japan</option>
</select>

I think You got the idea. Could you please give a help to me

rgds
Jotis

Last edited by jotis1 : 10-11-2009 at 12:34 PM.
Reply With Quote
  #2 (permalink)  
Old 10-11-2009, 06:26 PM
Ariel_Z's Avatar
Basic4ppc Veteran
 
Join Date: May 2009
Posts: 246
Default

Try adding an ArrayList. Insert the ID (country_code) to the ArrayList by adding a line after
Code:
ListBoxCountry.Add(Reader.GetValue(1))
as follows (ArrayList1 is the arraylist you've added):
Code:
ArrayList1.Add(Reader.GetValue(0))
Then in the SelectionChanged Event, get the value in the right place in the arraylist:
Code:
countCode = ArrayList1.Item(ListBoxCountry.SelectedIndex)
Reply With Quote
  #3 (permalink)  
Old 10-12-2009, 02:21 AM
Junior Member
 
Join Date: Oct 2009
Location: India
Posts: 11
Default

Hi Ariel,

Thank you very much.
It is working.

Thanks and regards
Jotis

Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox and enter key tsteward Questions (Windows Mobile) 2 10-14-2008 06:30 AM
Lookup Contacts using a listbox thartung Questions (Windows Mobile) 9 02-27-2008 09:16 AM
How to fix ListBox Items? Stellaferox Questions (Windows Mobile) 12 02-22-2008 09:50 AM
Listbox difficulties. dan kabestan Questions (Windows Mobile) 2 12-15-2007 06:24 PM
listbox = arraylist ? sloopa Questions (Windows Mobile) 1 05-07-2007 12:38 PM


All times are GMT. The time now is 10:30 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0