Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
194 views
in Technique[技术] by (71.8m points)

node.js - Unable to connect to the database: Invalid arguments: "instanceName" must be a string

I am new to Node.js and react so for any help I get I will be thankful. I am trying to connect to my local database on Azure Data Studio, but I get az connection error and I don't know how to fix it:

Unable to connect to the database: ConnectionError [SequelizeConnectionError]: Invalid arguments: "instanceName" must be a string
    at ConnectionManager.connect (/home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/sequelize/lib/dialects/mssql/connection-manager.js:118:15)
    at async ConnectionManager._connect (/home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:318:24)
    at async /home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:250:32
    at async ConnectionManager.getConnection (/home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:280:7)
    at async /home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/sequelize/lib/sequelize.js:613:26
    at async Sequelize.authenticate (/home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/sequelize/lib/sequelize.js:867:5) {
  parent: TypeError: Invalid arguments: "instanceName" must be a string
      at InstanceLookup.instanceLookup (/home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/tedious/lib/instance-lookup.js:39:13)
      at Connection.initialiseConnection (/home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/tedious/lib/connection.js:1065:51)
      at Connection.enter (/home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/tedious/lib/connection.js:2534:12)
      at Connection.transitionTo (/home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/tedious/lib/connection.js:1612:24)
      at Connection.connect (/home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/tedious/lib/connection.js:1026:10)
      at /home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/sequelize/lib/dialects/mssql/connection-manager.js:65:22
      at new Promise (<anonymous>)
      at ConnectionManager.connect (/home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/sequelize/lib/dialects/mssql/connection-manager.js:62:20)
      at ConnectionManager._connect (/home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:318:61)
      at async /home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:250:32,
  original: TypeError: Invalid arguments: "instanceName" must be a string
      at InstanceLookup.instanceLookup (/home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/tedious/lib/instance-lookup.js:39:13)
      at Connection.initialiseConnection (/home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/tedious/lib/connection.js:1065:51)
      at Connection.enter (/home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/tedious/lib/connection.js:2534:12)
      at Connection.transitionTo (/home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/tedious/lib/connection.js:1612:24)
      at Connection.connect (/home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/tedious/lib/connection.js:1026:10)
      at /home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/sequelize/lib/dialects/mssql/connection-manager.js:65:22
      at new Promise (<anonymous>)
      at ConnectionManager.connect (/home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/sequelize/lib/dialects/mssql/connection-manager.js:62:20)
      at ConnectionManager._connect (/home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:318:61)
      at async /home/andra/Documents/TW/ProiectTWLinux/Continuous-Feedback-App/back-end/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:250:32

The project I work on is a continuos feedback app. Here is my database configuration:

import Sequelize from 'sequelize';
import dotenv from 'dotenv';
dotenv.config();
const db = new Sequelize({
    dialect: 'mssql',
    dialectOptions: {
        instanceName: 'MSSQLSERVER2014'
    },
    database: 'ContinuousFeedback',
    username: process.env.DB_USER,
    host: 'localhost',
    port: process.env.DB_PORT || undefined,
    password: process.env.DB_PASS,  
    validateBulkLoadParameters: true,
    define: {
    timestamps: false,
    freezeTableName: true
    }  
})

export default db;
question from:https://stackoverflow.com/questions/65844584/unable-to-connect-to-the-database-invalid-arguments-instancename-must-be-a-s

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...