Acess SQL server Data in node js/Failed to connect to localhost:1433 - Could not connect (sequence)

Опубликовано: 16 Апрель 2020
на канале: timeoutexpired
6,908
37

This is the video to get SQL Server data using node.js and also
in this video you will see the solution of below errors,
1. Failed to connect to localhost:1433 - Could not connect (sequence).

This is fetch SQL data using node js
or
get SQL data using node js

if you got error Cannot find module 'express' then run command on command prompt
npm install express

if you got error Cannot find module 'mssql' then run command on command prompt
npm install mssql

1. create table
CREATE TABLE [dbo].[tblprod](
[prodcode] [int] NOT NULL,
[prodname] [nchar](10) NULL
)


2. server.js code
var express = require('express');
var app = express();

app.get('/', function (req, res) {

var sql = require("mssql");
// config for your database
var config = {
user: 'sa',
password: 'abc!1234',
server: 'localhost',
database: 'sample'
};

// connect to your database
sql.connect(config, function (err) {

if (err) console.log(err);

// create Request object
var request = new sql.Request();

// query to the database and get the records
request.query('select prodcode,prodname from tblprod ', function (err, recordset) {

if (err) console.log(err)

// send records as a response
res.send(recordset);

});
});
});

var server = app.listen(5000, function () {
console.log('Server is running..');
});


Смотрите видео Acess SQL server Data in node js/Failed to connect to localhost:1433 - Could not connect (sequence) онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь timeoutexpired 16 Апрель 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 6,908 раз и оно понравилось 37 людям.