I've recently started using Microsoft Azure services. I created a database and I'm trying to connect to it using nodejs. I was using mysql module to connect to databases, but now I have to use the mssql module. I tried to work through it using some examples from the documentation but I can't get it done.
Here is my connection:
let sql = require('mssql');
let config = require('./config');
const pool1 = new sql.ConnectionPool(config, err => {
if (err) throw err
// Query
pool1.request() // or: new sql.Request(pool1)
.query('select * from number', (err, result) => {
// ... error checks
if (err) throw err
console.dir(result)
console.log("connected")
})
})
My config:
connection: {
server : 'serverName.database.windows.net',
user : 'user@serverName',
password : 'password',
database : 'dbName',
port: 1433,
options: {
encrypt: true
}
}
Ultimately the error I ended up with is:
(node:2036) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): ReferenceError: value is not defined
via Bogdan Daniel
No comments:
Post a Comment