Setting values

Hello!

My situation is this: I have a J form with buttons and text boxes as my GUI, and i have another class which makes the connection to the database. I'm doing CRUD operations with my GUI, but the only problem is with the select.

I have a text box that accepts the employee ID, so when i press the button i pass this number to the class, the class connects to the DB and gets the desired row. Now how can i set those values i get from the DB in to the GUI's text boxes? :

[496 byte] By [River_Platea] at [2007-11-27 11:58:44]
# 1

well sure, check out the API docs

if you can get the employeeID from the GUI text box, you can certainly set it

in fact, i'd bet the function is called setText() :-)

SoulTech2012a at 2007-7-29 19:21:30 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

I'm going to post the methods that are going to interact with the select:

First the the one who passes the ID number:

private void btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {

String x = txtID.getText();

int z = Integer.parseInt(x);

Conexion c = new Conexion();

c.seleccion(Nombre);

c.seleccion(Apellido);

}

And this one is the Method that does the Select:

public void seleccion(int z, String Nombre, String Apellido){

Connection con;

Statement stmt;

ResultSet rs;

try{

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

}

catch(Exception e){

System.out.println("No se pudo lograr la conexion");

}

try{

con = DriverManager.getConnection("jdbc:odbc:con_sql","","");

stmt = con.createStatement();

rs = stmt.executeQuery("SELECT Nombre, Apellido FROM dbo.xxx WHERE ID=" + z);

while(rs.next()){ // El metodo .next() se mueve a la siguiente fila"si hay una" en la bd //

String Nom = rs.getString("Nombre");

String Ape = rs.getString("Apellido");

Formulario f = new Formulario();

f.setName(Nombre);

f.setName(Apellido);

}

}

catch(Exception e){

System.out.println("Error al seleccionar Empleado" + " "+ e);

}

}

River_Platea at 2007-7-29 19:21:30 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...