Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting ESOCKET error while connecting to SQL Server

Tried enabling SQL Server browser and also TCP, didn't solved the problem.

var sqlDb = require('mssql');

var config = {
    user: 'sa',
    password: 'sa',
    server: 'ABHISHEK28069',
    database: 'Ultratech',
    port: 1433,
    };

exports.executeSql = function (sql, callback) {

    var conn = new sqlDb.ConnectionPool(config);
    conn.connect()
        .then(function () {
            var req = new sqlDb.Request(conn);
            req.query(sql)
                .then(function (recordset) {
                    callback(recordset);
                })
                .catch(function (err) {
                    console.log(err);
                    callback(null, err);
                });
        })
        .catch(function (err) {
            console.log(err);
            callback(null, err);
        })
};
like image 544
abhishek reddy Avatar asked Sep 13 '26 22:09

abhishek reddy


1 Answers

Found solution, Forgot to restart the MSSQL service after enabling/starting TCP and MSSQL server browser services in configuration manager.

like image 180
abhishek reddy Avatar answered Sep 15 '26 12:09

abhishek reddy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!