I am very new to node.js and am now trying to build a connection using node.js to a MSSQL database. When the codes are being simpler say something like this:
var sql = require("mssql");
const pool = sql.connect('mssql://username:password@localhost/database')
The console doesn't give me any warning or errors on running the line for connection. I thought that means I'm good so I tried some other things but it says TypeError: sql.Conection is not a constructor when I was trying on this:
var dbConfig = {
server: "localhost\\server",
database: "database",
user: "user",
password: "password",
port: 1433
};
function getEmp() {
var conn = new sql.Connection(dbConfig);
//Some other codes...
}
And if I try to remove the new over there it says TypeError: sql.Conection is not a function on the console.
This makes me feel like it suddenly not recognizing the sql but I was not getting such an error with the simple version of the code.
So my question is what was wrong with the code and if it did work in the first code and how to make the second code work.
Thanks in advance.
via Jenny L.
No comments:
Post a Comment