tables rows problem with access

dear people..

in this code i wanted to get all rows from table "topic"

and add them to string "subject"

and the string "subject"

with be sent over a socket to a client

the client will only tokenize them and add every token

to a combo box.

when the program runs

the client adds "ONLY" the last row from the whole table

why that

?

can any one fix the problem

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con1 = DriverManager.getConnection("jdbc:odbc:votedb");

String sat="select topicid,subject from topic";

PreparedStatement ps = con1.prepareStatement(sat);

String subject=null;

while(rs.next())

{

String linein=rs.getString(1);

String linein2=rs.getString(2);

subject=linein+"-"+linein2;

}

out.println(subject);

}

catch(Exception e){}

[1316 byte] By [mublata] at [2007-11-27 5:35:02]
# 1
If you want to call "out.println(subject)" once for each record then you will want to put that inside the loop, instead of outside where it will only be called after the last record is read.
DrClapa at 2007-7-12 15:03:40 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...