Error SQL: Unknown column 'ASD123' in 'where clause'
Publicado por Alejandro (21 intervenciones) el 27/08/2019 14:43:59
El codigo:
Me tira este error:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
DecimalFormatSymbols separadoresPersonalizados = new DecimalFormatSymbols();
separadoresPersonalizados.setDecimalSeparator('.');
DecimalFormat formato1 = new DecimalFormat("#.00", separadoresPersonalizados);
String codigo = "";
String cantidad = "";
String cant1 = "";
float cant2;
float cant3;
float resultado;
String cant4 = "";
int confirmar = JOptionPane.showConfirmDialog(null, "¿Desea Actualizar los articulos cargados?", "Actualizar", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if(confirmar == JOptionPane.YES_OPTION){
for(int i = 0; i < tablaproducto.getRowCount(); i++){
codigo = tablaproducto.getValueAt(i, 0).toString();
cantidad = tablaproducto.getValueAt(i, 1).toString();
ResultSet rs = null;
PreparedStatement pst = null;
try{
String sql = "SELECT cantidad FROM articulos WHERE cod="+codigo+"";
pst =connect().prepareStatement(sql);
rs = pst.executeQuery();
while(rs.next()){
cant1 = rs.getString("cantidad");
JOptionPane.showMessageDialog(rootPane, cant1);
}
cant2 = Float.parseFloat(cantidad);
cant3 = Float.parseFloat(cant1);
resultado = cant2 + cant3;
cant4 = String.valueOf(formato1.format(resultado));
}catch(Exception e){
System.err.println("Error" + e);
}
String cant5 = cant4;
String punit = tablaproducto.getValueAt(i, 3).toString();
String sql = "UPDATE articulos SET cantidad=?, preciocosto=? WHERE cod="+codigo+"";
try{
pst = connect().prepareStatement(sql);
pst.setString(1, cant5);
pst.setString(2, punit);
int n = pst.executeUpdate();
if(n != 0){
JOptionPane.showMessageDialog(rootPane, "Registro Modificado con Exito!");
}else{
JOptionPane.showMessageDialog(rootPane, "No se a podido Modificar el Registro!");
}
}catch(Exception e){
System.err.println("Error" + e);
}
}
}
Me tira este error:
Valora esta pregunta


0