java - Syntax error (missing operator) in query expression 'Nombreproductos ==' some product ' -
i have code:
try{ class.forname("sun.jdbc.odbc.jdbcodbcdriver"); string db = "jdbc:odbc:driver=microsoft access driver (*.mdb);dbq=productosh.mdb"; connection con = drivermanager.getconnection(db, "", ""); statement s = con.createstatement(); resultset hola = s.executequery("select precioventau productos nombreproductos == '"+jcombobox1.getselecteditem()+"'"); while (hola.next()){ double preciou = hola.getdouble("precioventau"); system.out.println(preciou); jtextfield5.settext(string.valueof(preciou)); } } catch(classnotfoundexception | sqlexception e){ joptionpane.showmessagedialog(null, e); e.printstacktrace(); }
supossed set in textfield result of query. raise exception can't figure how solve it.
java.sql.sqlexception: [microsoft] [odbc microsoft access driver] syntax error (missing operator) in query expression 'nombreproductos ==' product '
but nombreproductos
field in table productos
.
when comparing strings in sql can use '=' or keyword like
resultset hola = s.executequery("select precioventau productos nombreproductos = '"+jcombobox1.getselecteditem()+"'"); while (hola.next()){ resultset hola = s.executequery("select precioventau productos nombreproductos '"+jcombobox1.getselecteditem()+"'"); while (hola.next()){
the difference between '=' , like
'=' must same match. 'like' able use wildcards.
Comments
Post a Comment