The connection string with the username password server and database is down below:
//imports
const express = require('express');
const mssql = require('mssql');
const body_parser = require('body-parser');
const app = express();
app.use(body_parser.json())
//connection string
const dbConfig = {
authentication: "Windows Authentication",
username: "LAPTOP-JTDH0LQ5\Harsh",
server: "LAPTOP-JTDH0LQ5\SQLEXPRESS",
database: "crud_form",
port: 1433
};
mssql.connect(dbConfig , err => {
if (err){
console.log("Error " + err.message);
}
else{
console.log("Successful Connection!");
}
})
When I run the code it says Server running on PORT 3000
for the first 15 seconds after which it crashes and says:
Failed to connect ‘LAPTOP-JTDH0LQ5SQLEXPRESS in 15000ms’
although the verification details are alright
The TC/IP is enabled.
I checked the connection string again and verified the details with the SQL Server running.
I’ve restarted the SQL Server and the NodeJS server as well.
The problem still persists.
Ashmit Srivastava is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.