Q:

incorrect syntax near '=' error

I just want to retrieve the image path from my db where im providing the table name at runtime but and id too problem heres arise is that its giving me error of incorrect syntax near '='
here is my query
string query = "select strImage from " + tableName + "where intID ="+Id;

A:

you need to add extra space before the WHERE clause,
string query = "SELECT strImage FROM " + tableName + " WHERE intID ="+Id;
                                                   -- ^ HERE

Let's say the value of the variable tableName is Hello, when it is concatenated, the query will looked like this,
SELECT strImage FROM HelloWHERE intID =0
                      --  ^ lacking space here

