Guest User

Untitled

a guest
Feb 12th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. app.get('/app/users', async (res, req) => {
  2. try {
  3.  
  4. const config=
  5. {
  6. server: 'localhost',
  7. database: 'HimHer',
  8. user: 'sa',
  9. password: 'Jessejames01',
  10. port: 1433
  11. }
  12.  
  13. let pool = await sql.connect(config)
  14. let result1 = await pool.request().query('select top 1 * from dbo.Users');
  15.  
  16. console.dir(result1);
  17. res.send(JSON.stringify(result1));
  18.  
  19.  
  20. } catch (err) {
  21. // ... error checks
  22. }
  23. })
  24.  
  25. sql.connect(config).then(pool => {
  26. // Query
  27.  
  28. return pool.request().query('select * from dbo.Users')
  29. }).then(result => {
  30. console.dir(result);
  31. res.send(JSON.stringify(result));
  32.  
  33. }).catch(err => {
  34. console.log('Exception:+ '+err);
  35. sql.close();
  36. })
  37.  
  38. new mssql.connect(configuration, error =>
  39. {
  40. new mssql.request().query('Select * from Users', (err, dataset) =>
  41. {
  42. if(err)
  43. {
  44. console.log(err);
  45. res.send(err);
  46. return;
  47. }
  48. else
  49. {
  50. console.dir(dataset);
  51. res.send(JSON.stringify(dataset));
  52. return;
  53. }
  54.  
  55.  
  56. });
  57. });
  58.  
  59. mssql.close();
Add Comment
Please, Sign In to add comment