Advertisement
Guest User

Untitled

a guest
Oct 14th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. exports.index = function (req, res) {
  2. var query = "SELECT P.pid, P.title, P.tags, P.topic, P.body_preview FROM Posts P ORDER BY P.date_created DESC";
  3.  
  4. new req.sql.Request().query(query, function (err, recordset) {
  5. if (err) throw err;
  6.  
  7. res.render('index', {
  8. rows: recordset
  9. });
  10. });
  11.  
  12. exports.g_login = function (req, res) {
  13. res.render('auth/login');
  14. }
  15.  
  16. Express server listening on port \.pipe7a9d4df2-518e-4eb1-afbe-74064c927cbf
  17. Sat Oct 14 2017 23:17:24 GMT+0000 (Coordinated Universal Time): Application has thrown an uncaught exception and is terminated:
  18. ConnectionError: Connection is closed.
  19. at D:homesitewwwrootnode_modulesmssqllibmain.js:1569:17
  20. at nextTickCallbackWith0Args (node.js:420:9)
  21. at process._tickCallback (node.js:349:13)
  22.  
  23. var sql = require("mssql");
  24.  
  25. // Setup for Azure SQL Server
  26. var config = {
  27. user: env.username,
  28. password: env.password,
  29. server: "mydomain.database.windows.net",
  30. database: "blog",
  31.  
  32. // As per the npm docs, encrypt=true for Azure connections
  33. options: {
  34. encrypt: true
  35. }
  36. };
  37. sql.connect(config, function (err) {
  38. if (err) throw err;
  39. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement