Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: jCombobox foreign key insert into

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default jCombobox foreign key insert into

    Hello, I am new to forum.

    I could use some help with code. I having problem how to make jcombobox to display names but to insert integer into database. Here's my code:

    [Java] ///Populate jComboBox private void FillCombo(){ String sql = "Select I - Pastebin.com

    jComboBox1.addItem(gggg +"."+" "+" "+ nme +" "+ ggg); First object gggg (int) is there a way I call only it when inserting into database? I tried .getItemAt(1) and .getSelectedIndex()... But no use...

    Everything works fine if i use jcombobox to show ID primary numbers from database, than i can insert into foreign key with .getSelectedItem(); But i need it to display name of person and to insert it's ID number.


  2. #2
    Junior Member
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: jCombobox foreign key insert into

    Solved. Friend helped me. Just split string.

Similar Threads

  1. JComboBox
    By ikocijan in forum What's Wrong With My Code?
    Replies: 9
    Last Post: July 16th, 2012, 06:35 AM
  2. How to insert date in database
    By AJAXx195 in forum JDBC & Databases
    Replies: 1
    Last Post: January 24th, 2012, 03:26 PM
  3. JComboBox
    By SV25 in forum Java Theory & Questions
    Replies: 2
    Last Post: April 20th, 2011, 08:47 AM
  4. [SOLVED] JCombobox help
    By sman36 in forum AWT / Java Swing
    Replies: 10
    Last Post: August 11th, 2010, 04:11 AM
  5. JComboBox
    By nasi in forum AWT / Java Swing
    Replies: 1
    Last Post: April 29th, 2010, 08:40 AM