I keep getting an error while trying to parse a parametrized query. Error: Token in error = @tableName
Seems that everything is ok with the variables, tried passing strings still the same.
using (SqlCeCommand command = new SqlCeCommand("SELECT * FROM @tableName WHERE @columnName = @id", connection))
{
command.Parameters.Add(new SqlCeParameter("tableName", tableName));
command.Parameters.Add(new SqlCeParameter("columnName", column));
command.Parameters.Add(new SqlCeParameter("id", id));
EDIT1:
Yes it might be wrong way of querying the database. For example if you need to access different tables at a different time of runtime whats the most suitable way of doing it. I mean the architecture of the class which accesses the database.
I am trying to use this to access two tables at a different runtime. I just pass these three variables and return the output.
P.S apologise if im breaking the rules.
EDIT2:
Sorry if I didnt make it clear but theres my question.
What architecture(if I can call that) is better for accessing different database tables at a different time while running the application? I mean what would be your solution to that? Is it good or bad and so on.