Inserting table field into query string
-
Hello, I have what I think is a simple task, but I have yet to find the answer. I'm trying to insert a table field into a query string from a dropdown list. I'm using MySql for a database, and if I use a control parameter, it inserts the selected value from the dropdown into the query with single quotes, like 'xxx'. MySql wants field name to be unquoted, like xxx. My query is like SELECT name, number, city FROM mytable WHERE xxx LIKE 'something';. And I can't figure out how to insert the xxx into the query without the quotes. I was wondering if any of you have ever done something like this where you entered a field name into a query string. I'm sure this is done somehow. I can't imagine not being able to do this. Any suggestion, and I mean ANY suggestion will be welcomed. How would you do it with MSsql or access?
-
Hello, I have what I think is a simple task, but I have yet to find the answer. I'm trying to insert a table field into a query string from a dropdown list. I'm using MySql for a database, and if I use a control parameter, it inserts the selected value from the dropdown into the query with single quotes, like 'xxx'. MySql wants field name to be unquoted, like xxx. My query is like SELECT name, number, city FROM mytable WHERE xxx LIKE 'something';. And I can't figure out how to insert the xxx into the query without the quotes. I was wondering if any of you have ever done something like this where you entered a field name into a query string. I'm sure this is done somehow. I can't imagine not being able to do this. Any suggestion, and I mean ANY suggestion will be welcomed. How would you do it with MSsql or access?
use String.Replace("'","") on the field name string you ar inserting into your query this would remove the 's