我必须从我的节点js express应用程序中的SQL Server中读取名为dbo.Index
的表,但是该表失败并且什么也不返回。
这是我的代码:
app.get('/getData',(req,res,next) => {
const config = {
user: 'sa',password: '12345',server: 'localhost',database: 'myDB'
}
const pool = new sql.ConnectionPool(config)
pool.connect(err => {
if (err) console.log(err)
console.log('connected.')
const request = new sql.Request(pool)
request.query(`SELECT * FROM dbo.Index`,(error,recordSet) => {
if (err) console.log(error)
res.send(recordSet)
})
})
})
我已经测试了这段代码,并且可以与其他表一起很好地工作,但是使用特定名称dbo.Index
时,它将失败。
我有必要阅读它,并且我不能更改表名(没有权限)。
我使用 node-mssql 软件包来连接到数据库。