A
A
antihrust2020-05-19 14:58:57
SQL
antihrust, 2020-05-19 14:58:57

Error code: 'ELOGIN'?

Code from app.js:

'use strict';

const PORT = 3000;

var express = require('express')
var bodyParser = require('body-parser')
var app = express();
var routes = require('./routes/index')

var publicDir = (__dirname + '/public');

app.use(express.static(publicDir));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.listen(PORT, () => { console.log("ASOM API running") });


Code from db.js:

const sql = require('mssql')
var config = {
    user: 'sa',
    password: '******',
    server: 'localhost',
    database: 'ASOM',
    "options": {
        "encrypt": true,
        "enableArithAbort": true
    }
};

const poolPromised = new sql.ConnectionPool(config)
    .connect()
    .then(pool => {
        console.log('Connected to MSSQL')
        return pool
    }).catch(err => console.log('Database connection failed! Bad congig: ', err))


module.exports = {sql,poolPromised}


Code from index.js:
var API_KEY = "1234"

var express = require('express')
var router = express.Router();
const { poolPromise, sql } = require('../db')

router.get('/', function (req, res) {
    res.end("API RUNNING")
});

module.exports = router;

When I try to connect to the server through Visual Studio, I get an error message: 'An error occurred while logging in to the user "sa".',
code: 'ELOGIN'
},
name: 'ConnectionError'

Connects stably through SSMS

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2020-05-20
@tsklab

Look at the MS SQL log.

To improve security, the error message returned to the client intentionally hides the nature of the authentication error. However, in the SQL Server error log, the associated error has a status that can be mapped to authentication failure conditions. Compare the error status with the following list to determine the cause of the login failure.
Link in previous question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question