I am trying to connect to a remote sql server database which is hosted in a remote server using node js. Now, I tried to connect to the same database using c# and everything works perfect but I tried the same thing with Node and I keep getting error logs. I am unable to understand if the problem is at my end or is it the problem with the server.
var sql = require('mssql');
var config = {
userName: 'realm',
password: 'friend',
server: '172.10.3.22',
options: {
database: 'ElmaTest',
instancename: 'SQL2014'
}
};
var updateMember = function( username, password) {
return sql.execute( {
procedure: "updateMember",
params: {
firstName: {
type: sql.NVARCHAR,
val: username
},
lastName: {
type: sql.NVARCHAR,
val: password
}
}
} );
};
function connecttoDb() {
// updateMember("elma","pass1234");
sql.connect(config, function (err) {
if (err) console.log("message" + err);
});
}
module.exports.datavalue = connecttoDb();
Error logs:- Example app listening at http://:::8081 messageConnectionError: Failed to connect to 172.10.3.22:1433 - connect ECONNREF USED 172.10.3.22:1433
The thing is that the same connection string works with c# but refuses to work with Node js.
C# connection string:
<add name="ElmaReport" connectionString="Data Source=172.10.3.22\SQL2014;Initial Catalog=ElmaTest;User ID=realm;password=friend" providerName="System.Data.SqlClient" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.