我需要进行如下查询:
SELECT * FROM Table WHERE Row.DATA = value
我需要在DATA
处经过SqlParameter
。如果我做这样的事情:
string value = "DATA";
SqlCommand sql = new SqlCommand("SELECT * FROM Table WHERE Row.@Val = value");
sql.Parameters.Add("@Val", SqlDbType.VarChar).Value = value;
我收到以下无效的查询:
SELECT * FROM Table WHERE Row.'DATA' = value
答案 0 :(得分:1)
string value = "DATA";
SqlCommand sql = new SqlCommand($"SELECT * FROM Table WHERE Row.{value} = value");