Nodejs mssql ConnectionError: Foydalanuvchi uchun foydalanuvchi "

Bu mening kodim:

var sql = require("mssql");

var dbConfig = {
server: "server",
username: "user",
password: "password",
database: "database"
};

function getEmp() {
var conn = new sql.Connection(dbConfig);
console.log(conn);
var req = new sql.Request(conn);
conn.connect(function (err) {
    if (err) {
        console.log(err);
        return;
    }
    req.query("SELECT * FROM Alg.User", function (err, recordset) {
        if (err) {
            console.log(err);
            return;
        }
        else {
            console.log(recordset);
        }
        conn.close();
    });
});
}

getEmp();

Va bu men kirib kelgan xato:

 { ConnectionError: Login failed for user ''.
at Connection. (c:\users\milan\documents\visual studio 2015\Projects\SampleSQLConn\SampleSQLConn\node_modules\mssql\lib\tedious.js:378:25)
at Connection.g (events.js:291:16)
at emitOne (events.js:96:13)
at Connection.emit (events.js:188:7)
at Connection.processLogin7Response (c:\users\milan\documents\visual studio 2015\Projects\SampleSQLConn\SampleSQLConn\node_modules\tedious\lib\connection.js:672:16)
at Connection.message (c:\users\milan\documents\visual studio 2015\Projects\SampleSQLConn\SampleSQLConn\node_modules\tedious\lib\connection.js:1082:21)
at Connection.dispatchEvent (c:\users\milan\documents\visual studio 2015\Projects\SampleSQLConn\SampleSQLConn\node_modules\tedious\lib\connection.js:519:45)
at MessageIO. (c:\users\milan\documents\visual studio 2015\Projects\SampleSQLConn\SampleSQLConn\node_modules\tedious\lib\connection.js:439:23)
at emitNone (events.js:86:13)
at MessageIO.emit (events.js:185:7)
name: 'ConnectionError',
message: 'Login failed for user \'\'.',
code: 'ELOGIN' }

Har kim nima qilayotganimni yaxshi biladi. O'zgaruvchan foydalanuvchi nomim bilan bog'lanishga o'xshashmi? Lekin nima sababdan men buni bilmayman ...

Oldindan rahmat!

Biznes:

Muammo shundaki, dbConfig da foydalanuvchi nom o'zgaruvchisi foydalanuvchi tomonidan o'zgartirilishi kerak! Va SQL so'rovi ham noto'g'ri, u [Alg] bo'lishi kerak [User], chunki "User" - bu kalit so'z!

2

6 javoblar

Iltimos, konfiguratsiyadagi "foydalanuvchi" ga "foydalanuvchi" ni kiriting. Agar siz console.log (conn) dan foydalanmoqchi bo'lsangiz, ushbu konfiguratsiya userName o'rniga "user" dan foydalanayotganini ko'rasiz.

I have answered this question, please refer to SQL Server Error "[ConnectionError: Login failed for user '****'.] "while connecting SQL Server with Nodejs using MSSQL

2
qo'shib qo'ydi

Iltimos, konfiguratsiyadagi "foydalanuvchi" ga "foydalanuvchi" ni kiriting. Agar siz console.log (conn) dan foydalanmoqchi bo'lsangiz, ushbu konfiguratsiya userName o'rniga "user" dan foydalanayotganini ko'rasiz.

I have answered this question, please refer to SQL Server Error "[ConnectionError: Login failed for user '****'.] "while connecting SQL Server with Nodejs using MSSQL

2
qo'shib qo'ydi

Bu men uchun ishladi: Ning o'rniga

var sql = require("mssql");

I changed it to var sql = require("mssql/msnodesqlv8");

Men qattiq kodni foydalanuvchi nomi/parol qilmadim. Dbconfig quyidagi kabi ko'rinadi:

var db_config = {
                driver: "msnodesqlv8",
                server: "ServerName",
                database: "databaseName",
                options: {
                trustedConnection: true,
                useUTC: true
              }
            }

Umid qilamanki bu sizga yordam beradi

1
qo'shib qo'ydi
"Msnodesqlv8" modulini topa olmayapman
qo'shib qo'ydi muallif John, manba
Bu juda yaxshi ishlagan, rahmat!
qo'shib qo'ydi muallif Michael McQuade, manba

Bu men uchun ishladi: Ning o'rniga

var sql = require("mssql");

I changed it to var sql = require("mssql/msnodesqlv8");

Men qattiq kodni foydalanuvchi nomi/parol qilmadim. Dbconfig quyidagi kabi ko'rinadi:

var db_config = {
                driver: "msnodesqlv8",
                server: "ServerName",
                database: "databaseName",
                options: {
                trustedConnection: true,
                useUTC: true
              }
            }

Umid qilamanki bu sizga yordam beradi

1
qo'shib qo'ydi
"Msnodesqlv8" modulini topa olmayapman
qo'shib qo'ydi muallif John, manba
Bu juda yaxshi ishlagan, rahmat!
qo'shib qo'ydi muallif Michael McQuade, manba

Google tomoshabinlar uchun ...

Yuqoridagi qaror siz uchun ishlamasa. Server xizmatlaridan SQL Server brauzerini tekshirishingiz kerak.

U meni bir oz vaqtga tashladi

0
qo'shib qo'ydi

Google tomoshabinlar uchun ...

Yuqoridagi qaror siz uchun ishlamasa. Server xizmatlaridan SQL Server brauzerini tekshirishingiz kerak.

U meni bir oz vaqtga tashladi

0
qo'shib qo'ydi
NodeJS Uzbekistan
NodeJS Uzbekistan
152 ishtirokchilar

Guruh NodeJS bo'yicha muloqot qilish uchun ochilgan. Sizni qiziqtirsa: @nodejs_uz @react_uz @angular_uz @yiiframework_uz @js_uzb @typescript_uzb @vuejs_uz @ngTashkent @laravel_uz @uzdevgroup Ish o'rinlari @UzDev_jobs