0👍
var express = require(‘express’);
var app = express();
var sql = require("mssql");
// config for your database
var config = {
user: 'sa',
password: 'deegii2001060108',
server: 'localhost\\MSSQLSERVER',
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 * from tblGender', function (err, result) {
if (err) console.log(err)
// send records as a response
console.log(JSON.stringify(result));
});
});
- [Vuejs]-Vue.js no event emitted between child and parent components
- [Vuejs]-Adding a CNAME to Vue.js Project
-1👍
var mysql = require('mysql');
var result;
var con = mysql.createConnection({
host: "localhost\\MSSQLSERVER",
user: "sa",
password: "deegii2001060108",
database: "sample"
});
con.connect(function(err) {
if (err) throw err;
con.query("select * from tblGender", function (err, data, fields) {
if (err) throw err;
result = data;
});
console.log(json.stringify(result));
});
Source:stackexchange.com