Apparently, the following code does not print anything out as it is expected.. I am sure it is to do with the fact that I tried to put a list of items in to @namelist
. Clearly, it is not just a text replacement.
How can I solve this problem? Thanks
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
using (var cmd = connection.CreateCommand())
{
cmd.CommandText = @"select column_name, table_name from information_schema.columns where table_name in (@namelist)";
cmd.Parameters.AddWithValue("@namelist", "'tableOne', 'tableTwo'");
var reader = cmd.ExecuteReader();
while (reader.Read())
{
var a = reader[0];
Console.WriteLine(a);
}
}
}