Skip to content

Instantly share code, notes, and snippets.

@andy51002000
Created July 1, 2019 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andy51002000/16e94da17842ae960608f136986881a6 to your computer and use it in GitHub Desktop.
Save andy51002000/16e94da17842ae960608f136986881a6 to your computer and use it in GitHub Desktop.
read db
const sql = require('mssql')
const config = {
user: '',
password: '',
server: '', // You can use 'localhost\\instance' to connect to named instance
database: '',
options: {
encrypt: true // Use this if you're on Windows Azure
}
}
async function test() {
var queryString = "select * from activities"
const pool = new sql.ConnectionPool(config).connect();
var conn = await pool
const req = conn.request();
const result = await req.query(queryString)
var returnValue = result['recordset'][0]['Name']
pool.close()
return returnValue
}
try{
test()
}catch(err)
{
console.log(err.message)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment