Created
July 1, 2019 09:30
-
-
Save andy51002000/16e94da17842ae960608f136986881a6 to your computer and use it in GitHub Desktop.
read db
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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