I am totally new to ASP.NET and C#, and I am designing a web form. The user gives me some inputs, let's say keyvalue
, and I have to query a database using that parameter.
I have seen that it's possible to run a SQL query inside C#. In that example, however, the query string is fixed:
string queryString = "SELECT * FROM This.Table WHERE keyvalue = 'WINNIPEG'"
What if my keyvalue
comes from user input instead? Can I do something like:
string keyvalue = txtInputCell.Text
string queryString = "SELECT * FROM Table WHERE key = keyvalue"