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 3 of 3

Thread: My Access Database "memberID" now is until M15 , i want to get the next memberID "M16" , how to get it ?

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

    Default My Access Database "memberID" now is until M15 , i want to get the next memberID "M16" , how to get it ?

    This is my insert query~~ i need to get the next MemberID and display it in textfield(memberID_a).

    query = "INSERT INTO Membership VALUES ('" +memberID_a.getText() + "','" +memberName_a.getText() + "','" + icNo_a.getText() + "','" + gender_a.getText() +"','" + birthday_a.getText() +"','" + telephoneNo_a.getText() + "','" + mobileNo_a.getText() + "','" + email_a.getText() + "','" + address_a.getText() + "','" + postalCode_a.getText() + "','" + state_a.getText() + "','" + country_a.getText() + "','" + memberPoint_a.getText() + "');";



    try{

    stmtInsert = conn.createStatement();
    stmtInsert.executeUpdate(query);

    } catch(Exception ex){
    JOptionPane.showMessageDialog(null,"ERROR"+ex.toSt ring(),"ERROR",JOptionPane.ERROR_MESSAGE);
    }


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: My Access Database "memberID" now is until M15 , i want to get the next memberID "M16" , how to get it ?

    Do you have a question?
    Please see the Announcements page for the use of code tags

  3. #3
    Junior Member
    Join Date
    Jul 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: My Access Database "memberID" now is until M15 , i want to get the next memberID "M16" , how to get it ?

    Hi, can you be more specify on what you want?

    if by saying "get" you want to perform a "Select on DB" you can use this code

    String query = "select memberID_a from Membership where memberID_a = '"+memberID_a.getText()+"'";

       public void load_text(String query) {
            try {
                Statement st = conn.createStatement();
                ResultSet rs = st.executeQuery(query);
                while (rs.next()) {
                   memberID_a.setText(rs.getString("memberID_a"));
                }
                con.close();
     
            } catch (Exception e) {
                System.out.println("Error aqui: " + e);
     
            }
     
        }

Similar Threads

  1. Replies: 2
    Last Post: June 22nd, 2013, 10:30 AM
  2. Conceptual Questions Related To "super" keyword and "constructor".
    By wikki2013 in forum Java Theory & Questions
    Replies: 1
    Last Post: May 26th, 2013, 02:14 PM
  3. Replies: 3
    Last Post: December 7th, 2011, 02:03 AM
  4. Replies: 7
    Last Post: August 13th, 2011, 01:22 AM
  5. "java.lang.NoSuchMethodError: main" and "fatal exception occured."
    By joachim89 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 10th, 2010, 08:35 AM

Tags for this Thread