java sql SQLException: Parameter index out of range (1 > number of parameters, which is 0) -


I keep this error when I try to connect to the database.

This is my ready statement

  string sql = "select * fade '?` Homemog' = '?' "; Preparation of prepared space; Prepst = con.prepareStatement (SQL); Prepst.setString (. 1, box1.getSelectedItem () toString ()); Prepst.setString (.2, box1.getSelectedItem () toString ()); Rs = prepst.executeQuery ();  

Why does anyone get this error?

I think your problem is in the ' and `` symbols SQL should be corrected as follwing:

string sql = "select * from where home home =?";

Although I'm not sure that the parameter placeholder ? Supported after from to . Therefore, you must retain it yourself, ex:

  string table = box 1.get from the linked item (). ToString (); String sql = "SELECT * FROM" + table + "WHERE homeTam =?";  

Comments