How To Make button First , Previous , next and Last Swing JDBC
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: How To Make button First , Previous , next and Last Swing JDBC

  1. #1
    Join Date
    Jan 2008
    Posts
    5

    How To Make button First , Previous , next and Last Swing JDBC

    Hi ,

    How Can i Move to First , Last ,Previous Rows
    using JButton
    i have set ResultSet to first beforlast ...
    but doesnt seem to work for me

  2. #2
    Join Date
    Jan 2008
    Posts
    5

    Question Re: How To Make button First , Previous , next and Last Swing JDBC

    What ?

    Is it So difficult ?

    or i'am Not Clear ?

  3. #3
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: How To Make button First , Previous , next and Last Swing JDBC

    Quote Originally Posted by killer7k
    What ?
    What?

    Is it So difficult ?
    Don't know.

    or i'am Not Clear ?
    That's the one. Perhaps you could explain what you're talking about. We're not mind-readers.

    When a programming language is created that allows programmers to program in simple English, it will be discovered that programmers cannot speak English...
    Anon.
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  4. #4
    Join Date
    Jan 2008
    Posts
    5

    Re: How To Make button First , Previous , next and Last Swing JDBC

    oK !

    We Have a Table That Contains some data
    I can Get all Data in JTable
    & I Can Search for a Row(PrimaryKey) in TextBox
    What I need Is To Manipulate The Table
    Like If I Click on JButton First They Will Show me The first Row in Textbox
    if i click in next JButton You will Show me next one ....
    it's like With Ado.net (move first , move last ..)

  5. #5
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: How To Make button First , Previous , next and Last Swing JDBC

    Quote Originally Posted by killer7k
    We Have a Table That Contains some data
    A database table?
    I can Get all Data in JTable
    Good, that helps.
    I Can Search for a Row(PrimaryKey) in TextBox
    Are you saying you enter the key into a text field and somehow the corresponding row in the JTable is selected or highlighted?
    What I need Is To Manipulate The Table
    Like If I Click on JButton First They Will Show me The first Row in Textbox
    if i click in next JButton You will Show me next one ....
    You want buttons 'First', 'Next', & 'Previous' that will select the first, next, and previous rows from the JTable and also display them in a text field?
    it's like With Ado.net (move first , move last ..)
    What is Ado.net?

    If you can't explain it simply, you don't understand it well enough...
    A. Einstein
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  6. #6
    Join Date
    Jan 2008
    Posts
    5

    Re: How To Make button First , Previous , next and Last Swing JDBC

    oK Lets Forget JTable
    let's Say We Have a Table Name : Customer (CustomerId,Name,DateBirth)
    & I have 3 JtextField ,
    I Have a Jbutton Called Search That Search for a partiular Customer
    I enter in JtextField 1 (CustomerID) & It show me his name & DateBirth
    That is done work well

    what i need Now :
    Let's Say We have In The Table 5 Customer
    I need When To Click on Jbutton First Show The first Customer in JtextField
    & when I click on Next show me Next Customer , & when i Click in Jbutton Last Show me LastOne ...

    ado.net (its Vb.Net with Database)

  7. #7
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: How To Make button First , Previous , next and Last Swing JDBC

    If you only have a small number of records, you can read them all into the ResultSet and use the ResultSet methods to access the first, last, next, & previous. If the ResultSet doesn't support all the features you need, you can extract all the records from the ResultSet into an ArrayList (or other ordered collection class) and use the ArrayList methods to access the records you want. In general, it is better to copy records out of the ResultSet and free up the Statement as soon as possible.

    If you have a lot of records in the table, it's probably better to use SQL queries to retrieve the first, next, etc.

    Everything should be made as simple as possible, but not simpler...
    A. Einstein
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  8. #8
    Join Date
    Jan 2008
    Posts
    5

    Re: How To Make button First , Previous , next and Last Swing JDBC

    oK !

    I have Worked with The ResulSet Well
    & There are some method of ResultSet .first() , last()....
    but Cant Seem to work for me
    have You Succeded To get it to work ?

  9. #9
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: How To Make button First , Previous , next and Last Swing JDBC

    Quote Originally Posted by killer7k
    There are some method of ResultSet .first() , last()....
    but Cant Seem to work for me
    Did you set up the Statement to give you a scrollable ResultSet as described in the ResultSet API docs?
    Post up the full text of any errors you get.
    have You Succeded To get it to work ?
    I have used a scrollable ResultSet in the past, yes. But as I said, it's really better to copy the records out into a collection.

    Imagination is more important than knowledge...
    A. Einstein
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center