Skip to navigation
Simple access test from node to mssql
23.12.17
var express = require('express'); var app = express(); var sql = require("mssql"); // config for your database const config = { user: 'SA', password: 'PASS', server: '192.168.0.193', // You can use 'localhost\\instance' to connect to named instance database: 'SL', options: { encrypt: true // Use this if you're on Windows Azure } } app.get('/', function (req, res) { sql.connect(config).then(() => { return sql.query`select TOP 10 * from av0_style` }).then(result => { res.send(result); }).catch(err => { // ... error checks }) sql.on('error', err => { // ... error handler }) }); var server = app.listen(4000, function () { console.log('Server is running.. on Port 4000'); })
https://github.com/patriksimek/node-mssql
Reply
Anonymous
var express = require('express'); var app = express(); var sql = require("mssql"); const config = { user: 'SA', password: 'PASS', server: '192.168.0.1', database: 'SL', options:{encrypt: true} } app.get('/', function (req, res) { new sql.ConnectionPool(config).connect().then(pool => { return pool.query`select TOP 100 * from av0_style` }).then(result => { res.send(result); }).catch(err => { console.log(err) }) }); var server = app.listen(4000, function () { console.log('Server is running.. on Port 4000'); });
23.12.17
Reply
Anonymous
Information Epoch 1732678317
When in doubt, use brute force.
Home
Notebook
Contact us