Question

I added a connection and it shows up in "Other Connections" but I can't seem to reference it.

var db = Database.Open("MyNewConnection");

throws an exception: Connection string 'MyNewConnection' was not found.

Was it helpful?

Solution

Have you checked to make sure your connection string is correct in your web.config file?

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
   <add 
     name="MyNewConnection" 
     connectionString= "server=myServer;database=myDatabase;uid=username;pwd=password"
     providerName="System.Data.SqlClient" /> 

  </connectionStrings>
</configuration>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top