Question

I'm getting the "Database connection failed" trying with the Node.JS driver for SQL and the example from: http://blogs.msdn.com/b/sqlphp/archive/2012/06/08/introducing-the-microsoft-driver-for-node-js-for-sql-server.aspx

The string I use against SQL Server Express 11.0 64-bit, local

var conn_str = "Driver={SQL Server Native Client 11.0};Server=(local);Database=MyDB;Trusted_Connection={Yes}"; 

I also tried "sa" and another local user vs Windows Authentication -- all without luck.

Running node 0.6.10 (the version supported by the SQL driver), SQL Server Config showing SQL Native Client 11, so the versions match.

Are there any ways to troubleshoot?? Any guides / tutorials where the connection was successful for my stack?

Was it helpful?

Solution

RESOLVED:

I had been trying to incorrectly access the named instance of SQL Express. Should be .\\SQLEXPRESS, not (local) or .\SQLEXPRESS.

The correct String:

 var conn_str = "Driver={SQL Server Native Client 11.0};Server=.\\SQLEXPRESS;Database=NPv1;Trusted_Connection=Yes";

OTHER TIPS

Trusted connection tells the connection to use the Windows ID of the process. If you are hosting this in IIS, this id will be the one the application pool is using. Make sure this id has access to both the database server and the database. Using sa and other local users won't fix the problem unless you tell it to not use a trusted connection and then specify the user id and password in the connection string (btw, this approach is not recommended; stick with the trusted connection if you can).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top