Connection Error: Connection is Closed
See original GitHub issueHi…
I’m able to access my MSSQL from MSQL Studio. defined my index.js file as below, but it keeps give me this error:
{ [ConnectionError: Connection is closed.] name: ‘ConnectionError’, message: ‘Connection is closed.’, code: ‘ECONNCLOSED’}
what wrong I’m doing, if below is my code, thanks
var sql = require('mssql');
var config = { user: 'sa', password: 'bk123', server: 'HASN-BK\\SQLEXPRESS', database: 'BK',
stream: true }
sql.connect(config, function(err) {
var request = new sql.Request();
request.stream = true;
request.query('SELECT * from emp');
request.on('recordset', function(columns) {
console.log(columns);
// Emitted once for each recordset in a query
});
request.on('row', function(row) {
console.log(row);
// Emitted for each row in a recordset
});
request.on('error', function(err) {
console.log(err);
// May be emitted multiple times
});
request.on('done', function(returnValue) {
// Always emitted as the last one
});
});
Issue Analytics
- State:
- Created 9 years ago
- Comments:40
Top Results From Across the Web
How to Fix Error Connection Closed Error in Google Chrome?
How to Fix Connection Closed Error? · Check your internet connection · Check the firewall connection · Disable proxy server and VPN ·...
Read more >How To Fix "ERR_CONNECTION_CLOSED" in Chrome (13 ...
The ERR_CONNECTION_CLOSED message is an error that you might see in Chrome when you try to access a website. It means that something's...
Read more >How to Fix ERR Connection Closed Error in Chrome Browser
ERR Connection Closed Error in Chrome Browser · 1. Clear Browsing Data · 2. Disable Proxy Server · 3. Flush DNS and Reset...
Read more >ERR_CONNECTION_CLOSED: How to fix the connection error
How to fix the “ERR_CONNECTION_CLOSED” error · Solution 1: Check internet connection and restart router if necessary · Solution 2: Reset network ...
Read more >Node js: mssql [ConnectionError: Connection is closed.] name
but when savedquery is calling then connection close error occurs. each method code is similar to savedquery method (copy pasted code only queries...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I have the same issue when I run 2 or more queries one right after the other
Worked fine for me, better use a global connection rather connecting to the databse each time you have to make a request to avoid the ‘Connection is closed Error’.