Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.get('/app/users', async (res, req) => {
- try {
- const config=
- {
- server: 'localhost',
- database: 'HimHer',
- user: 'sa',
- password: 'Jessejames01',
- port: 1433
- }
- let pool = await sql.connect(config)
- let result1 = await pool.request().query('select top 1 * from dbo.Users');
- console.dir(result1);
- res.send(JSON.stringify(result1));
- } catch (err) {
- // ... error checks
- }
- })
- sql.connect(config).then(pool => {
- // Query
- return pool.request().query('select * from dbo.Users')
- }).then(result => {
- console.dir(result);
- res.send(JSON.stringify(result));
- }).catch(err => {
- console.log('Exception:+ '+err);
- sql.close();
- })
- new mssql.connect(configuration, error =>
- {
- new mssql.request().query('Select * from Users', (err, dataset) =>
- {
- if(err)
- {
- console.log(err);
- res.send(err);
- return;
- }
- else
- {
- console.dir(dataset);
- res.send(JSON.stringify(dataset));
- return;
- }
- });
- });
- mssql.close();
Add Comment
Please, Sign In to add comment