Hello.
I'm trying to pass a variable to my SQL Statement but it just won't output the correct results from the table.
It's nice and simple.
I have a value stored in a variable, so for example,
String abc;
This is fine, if I perhaps do out.println(abc); it will output the variable value depending on what the user enters.
Now though when I pass it to the SQL Statement, nothing...
selectStatement = "SELECT Emp_Name FROM Employees WHERE Emp_Sal = 'abc' ";
So I think you can see what I'm trying to do. The 'abc' value will be different depending on what salary the user enters for the search. However at the moment it is basically looking for a value called 'abc' and always finding nothing. How do I make it actually use the value stored within the variable and not just take the variable name???
Cheers.
I'm trying to pass a variable to my SQL Statement but it just won't output the correct results from the table.
It's nice and simple.
I have a value stored in a variable, so for example,
String abc;
This is fine, if I perhaps do out.println(abc); it will output the variable value depending on what the user enters.
Now though when I pass it to the SQL Statement, nothing...
selectStatement = "SELECT Emp_Name FROM Employees WHERE Emp_Sal = 'abc' ";
So I think you can see what I'm trying to do. The 'abc' value will be different depending on what salary the user enters for the search. However at the moment it is basically looking for a value called 'abc' and always finding nothing. How do I make it actually use the value stored within the variable and not just take the variable name???
Cheers.
