how to get to next record on click of a button

Thread Solved

Join Date: Mar 2007
Posts: 29
Reputation: bhuvan83 is an unknown quantity at this point 
Solved Threads: 0
bhuvan83's Avatar
bhuvan83 bhuvan83 is offline Offline
Light Poster

how to get to next record on click of a button

 
0
  #1
Mar 13th, 2007
hi every1
i m new to website development.
just learning it.
i have made a code in which i access my database(MS Access).
i m able to print the first record of the database on the page.
but i m not able to go to next record which i want to show on click of a button.
i dont want to use while(rs.next) as i dont want to show all the records at once.
the code i m writing is->


  1. <%@ page import="java.sql.*" %>
  2. <htmL>
  3. <%
  4. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  5. String dataSourceName="mydsn";
  6. String dbURL="jdbc:odbc:" + dataSourceName;
  7. Connection con= DriverManager.getConnection(dbURL,"","");
  8. Statement s=con.createStatement();
  9. s.execute("select * from web");
  10. ResultSet rs;
  11. rs=s.getResultSet() ;
  12. rs.next();
  13. %>
  14. <body>
  15. <script>
  16. function getDetails()
  17. {
  18. rs.next()
  19. }
  20. </script>
  21. <form method="post">
  22. Website:<input type="text" value="<%=rs.getString(1) %>"><br>
  23. <a rel="nofollow" class="t" href="http://www.daniweb.com/techtalkforums/<input" target="_blank">Url:<input</a> type="text" value="<%=rs.getString(2) %>"><br>
  24. Category: <input type="text" value="<%=rs.getString(3) %>"><br>
  25. Description: <input type="text" value="<%=rs.getString(4) %>"><br>
  26. Search Engine-><br>
  27. Yahoo: <input type="text" value="<%=rs.getString(5) %>"><br>
  28. Google: <input type="text" value="<%=rs.getString(6) %>"><br>
  29. Altavista: <input type="text" value="<%=rs.getString(7) %>"><br>
  30. <input type="button" value="Next" onClick="getDetails()">
  31. </form>
  32. </body>
  33. </html>
Last edited by bhuvan83; Mar 13th, 2007 at 7:53 am.
Bhuvan Aggarwal
There is no word impossible.
its i m possible
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,247
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 492
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: how to get to next record on click of a button

 
0
  #2
Mar 14th, 2007
Why don't you store whole databse into bean and then on button press request next set
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 29
Reputation: bhuvan83 is an unknown quantity at this point 
Solved Threads: 0
bhuvan83's Avatar
bhuvan83 bhuvan83 is offline Offline
Light Poster

Re: how to get to next record on click of a button

 
0
  #3
Mar 14th, 2007
bro thanks for ur reply.
but i dont know how to use beans.
can u show me a small code????
Last edited by bhuvan83; Mar 14th, 2007 at 6:14 am.
Bhuvan Aggarwal
There is no word impossible.
its i m possible
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,247
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 492
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: how to get to next record on click of a button

 
0
  #4
Mar 15th, 2007
nice explanation on wikipedia

bellow is how do I get data from my db about events in calendar
  1. CalendarData[] eArr = new CalendarData[exists];
  2. try
  3. {
  4. int i=0;
  5. strQuery = "select event_type, ev_date, ev_time, ev_description from calendar_events where userName='" + strUser + "' and cal_id='" + calId + "'";
  6. rs = stmt.executeQuery( strQuery);
  7. while( rs.next())
  8. {
  9. eArr[i] = new CalendarData();
  10. eArr[i].setEventType(rs.getString("event_type") );
  11. eArr[i].setEventDate(rs.getString("ev_date") );
  12. eArr[i].setEventTime(rs.getInt("ev_time") );
  13. eArr[i].setEventDescription(rs.getString("ev_description") );
  14. i++;
  15. } // end while loop
  16. session.setAttribute("eventArray", eArr);
  17. CalendarData[] test = (CalendarData[]) session.getAttribute("eventArray");

Also do not connect to DB from JSP use servlets
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 29
Reputation: bhuvan83 is an unknown quantity at this point 
Solved Threads: 0
bhuvan83's Avatar
bhuvan83 bhuvan83 is offline Offline
Light Poster

Re: how to get to next record on click of a button

 
0
  #5
Mar 16th, 2007
thanks got the soln
Bhuvan Aggarwal
There is no word impossible.
its i m possible
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for JSP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC