I am building a sql
query string like this:
var sqlDailyDataForOption = @"select underlying_symbol, quote_date
FROM [@val6]
Later I add the command line parameters
thus:
command.Parameters.AddWithValue("@val6", o.underlying_symbol + "_1545");
I get an exception
when I try to execute the query string
:
using (SqlDataReader reader = command.ExecuteReader())
{
- $exception {"Invalid object name '@val6'."} System.Data.SqlClient.SqlException
However, if I hardwire the value o.underlying_symbol + "_1545"
it works fine.
Is it that command-parameters
can't be dynamically created in a FROM
?