im connecting NodeJs with Sqlserver and have this error
ConnectionError: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
at PrivateConnection.callback2 (D:testnode_modulesmssqllibmsnodesqlv8connection-pool.js:46:1
const express = require('express');
const morgan = require('morgan');
const path = require('path');
const { engine } = require('express-handlebars');
const {conn, sql} = require('./connect')
const app = express();
const port = 3000;
app.use(express.static(path.join(__dirname, 'public')));
// http logger
app.use(morgan('combined'));
// template engine
app.engine('hbs', engine({
extname: '.hbs'
}));
app.set('view engine', 'hbs');
app.set('views', path.join(__dirname, 'resoures/views'));
app.get('/', (req, res) => {
res.render('home');
});
app.get('/tin-tuc', (req, res) => {
res.render('tin');
});
app.get('/search', (req, res) => {
res.render('search');
});
app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});
```this my Index.js file
const sql = require(‘mssql/msnodesqlv8’);
const config = {
server: “DESKTOP-0BKJQ7LMAY1”,
database: “testnodejs”,
driver: “msnodesqlv8”,
options: {
trustedConnection: true // Dùng cho Windows Authentication
}
};
const conn = new sql.ConnectionPool(config).connect().then(pool => {
console.log(‘Connected to SQL Server’);
return pool;
}).catch(err => {
console.error(‘Database Connection Failed!’, err);
return Promise.reject(err);
});
module.exports = {
conn: conn,
sql: sql,
};
[this my source](https://i.sstatic.net/pzzl967f.png)
i want to connect NodeJs with my database in SqlServer
Nguyễn Thị Thu Huyền is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.