Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how can i use a jComboBox using rowset

    Hello, i'm trying to use a jComboBox to search data on my database.

    i'm using this code:
    rs.setCommand("SELECT * FROM aanmeldingsformulier WHERE" + jComboBox1.getSelectedItem() + " = ?");

    but when a i run it gives me this error: java.sql.SQLException: no value specified for parameter 1.

    can someone help me?
    thnx

  • #2
    Regular Coder brad211987's Avatar
    Join Date
    Sep 2005
    Location
    Ohio
    Posts
    631
    Thanks
    10
    Thanked 50 Times in 50 Posts
    http://java.sun.com/j2se/1.5.0/docs/...esindex-1.html

    If you look at the Java API(linked above), JComboBox returns an Object. You will probably need to cast this as a String to place it in your query. On a side note, you may want to look into prepared statements, as they are generally considered more secure than concatenating strings dynamically in your query.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •