SQL Server登录失败求助:执行查询提示用户登录失败
求助:SQL Server 连接报错 "Login failed for user ' '"
我正在为个人网站搭建数据库,操作时始终遇到登录失败错误:
Error executing query: Login failed for user ' '
目前已确认以下信息:
- 服务器运行正常,单独的测试文件能验证连接成功
- SQL Server 已设置为混合身份验证模式
- 其他配置未发现明显异常
附上相关代码文件及配置,希望能定位问题所在:
dbConfig.js
const config = { name: 'ArtPortfolio', password: 'kierrarg', server: 'DESKTOP-DC3RG3A', database: 'Contact', options: { trustServerCertificate: true, enableArithAbort: true, }, port: 1433 } module.exports = config;
dbOperation.js
const config = require('./dbConfig'), sql = require('mssql'); const getContact = async() => { try { let pool = await sql.connect(config); let contact = pool.request().query("SELECT * from Contact") console.log(contact); return contact; } catch(error) { console.log('Error executing query:', error.message); } } module.exports = { getContact }
server.js
const express = require('express'), dbOperation = require('./dbfiles/dbOperation'), cors = require('cors'); const API_PORT = process.env.PORT || 5000; const app = express(); app.use(cors()); app.get('/api', function(req, res) { console.log('called'); res.send({result: 'hellloooo'}) }) app.get('/quit', function(req, res) { console.log('called'); res.send({result: 'byeeeeee'}) }) dbOperation.getContact().then(res => { console.log(res); }) app.listen(API_PORT, () => console.log(`Listening on port ${API_PORT}`));
package.json 新增配置
"proxy": "http://localhost:5000", "server": "nodemon server.js",
内容的提问来源于stack exchange,提问作者Kierra Gagnon
相关产品推荐
相关产品推荐

