Sql 靠近'的语法不正确=';错误

Sql 靠近'的语法不正确=';错误,sql,select,Sql,Select,我只想从我的数据库中检索映像路径,我在运行时提供了表名,但这里出现的id太多问题是,它给我的错误是“=”附近的语法不正确 这是我的问题 string query = "select strImage from " + tableName + "where intID ="+Id; 您需要在WHERE子句之前添加额外的空格 string query = "SELECT strImage FROM " + tableName + " WHERE intID ="+Id;

我只想从我的数据库中检索映像路径,我在运行时提供了表名,但这里出现的id太多问题是,它给我的错误是“=”附近的语法不正确

这是我的问题

string query = "select strImage from " + tableName + "where intID ="+Id;

您需要在
WHERE
子句之前添加额外的空格

string query = "SELECT strImage FROM " + tableName + " WHERE intID ="+Id;
                                                   -- ^ HERE
假设变量
tableName
的值是
Hello
,当它被连接时,查询将如下所示

SELECT strImage FROM HelloWHERE intID =0
                      --  ^ lacking space here

您需要在
WHERE
子句之前添加额外的空格

string query = "SELECT strImage FROM " + tableName + " WHERE intID ="+Id;
                                                   -- ^ HERE
假设变量
tableName
的值是
Hello
,当它被连接时,查询将如下所示

SELECT strImage FROM HelloWHERE intID =0
                      --  ^ lacking space here

我希望你的疑问是正确的。有点sytax问题。试试这个

string query = "select strImage from " + tableName + " where intID ="+Id;

我希望你的疑问是正确的。有点sytax问题。试试这个

string query = "select strImage from " + tableName + " where intID ="+Id;
字符串的串联会导致创建多个对象


字符串的串联会导致创建多个对象

如果OP使用
.net
这很好如果OP使用
.net