0

I'm using sails-sqlserver where my host is running both SQL Server 2008 and 2012. In connections.js - host: is set to 'SQLServerhost\2012' I am getting the error "error: A hook (orm) failed to load!" Is there a different way to specify which SQL Server to connect to?

Arnie P
  • 1
  • 1

1 Answers1

0

I've found success with the below format in /config/connections.js when I need to work with different databases on the same server (but see below suggestion):

sqlserverLOCAL: {
    adapter: 'sails-sqlserver',
    user: 'username',
    password: 'password',
    host: 'localhost',       // Name or IP Address of SQL Server
    port: '1433',
    database: 'YourDBName'   // i.e. Initial Catalog
},

sqlserver: {
    adapter: 'sails-sqlserver',
    user: 'username',
    password: 'password',
    host: '11.222.333.444',  // IP Address of SQL Server
    port: '1433',
    database: 'OtherDBName'  // i.e. Initial Catalog
}

In your case, perhaps setting both host: attributes to the same server (just SQLServerhost rather than SQLServerhost\2012) and then set the database: attribute to the appropriate Initial Catalog would be best. Also, make sure you double-check what ports the two SQL Servers are running on and set that attribute value accordingly.

jaygeek
  • 1,004
  • 10
  • 14
  • I have tried the following: theSqlServer: { adapter: 'sails-sqlserver', user: 'sa', password: 'pwd', host: '172.17.252.82', port: '49254', database: 'mydb', options: { encrypt: false // set to true for Azure databases } but still get the error: Loading the app's models and any custom adapters... Loading app models... error: A hook (`orm`) failed to load! Lowering sails... – Arnie P May 24 '16 at 17:04
  • You might temporarily try setting `migrate:` to safe in `/config/models.js` module.exports.models = { migrate: 'safe' }; More tips here: http://stackoverflow.com/questions/28524926/the-hook-orm-taking-too-long-to-load/35414335#35414335 – jaygeek May 24 '16 at 17:52
  • @ArnieP, Did you figure anything out on your settings? Did you try my `migrate:` suggestion? – jaygeek Jun 09 '16 at 20:13