Database name after underscore in connection string is ignored

I am trying to do something that I find very simple. I have a connection string that I am retrieving from the database. When I create a new instance of the SQL connection, it looks (when I debug and look at the object), similar to how it correctly fills the db connection string. However, the messasge error that I get makes me think that all information after the underscore in the database name is resolved.

Ex code:

Database db = new SqlDatabase(ConnectionString); // Connection string appears correct
DbCommand dbCommand = db.GetStoredProcCommand("StoredProcName");
DataSet approverDataset = db.ExecuteDataSet(dbCommand); // when this executes, exception is generated

When I run this code, I am greeted with the following exception message: Server manager "testdb_psidentity" cannot access the database "testdb" in the current security context

Here is my String connection:

DataSource=testserver.com;Database=testdb_ps;Trusted_Connection=false;uid=testdb_psidentity;pwd=testpwd

I tried changing this to:

DataSource=testserver.com;Database=[testdb_ps];Trusted_Connection=false;uid=testdb_psidentity;pwd=testpwd

, , , , . : "[testdb_ps]", . . 'testdb_psidentity'.

/ SQL-.

, testdb_ps? , , , .

+5
3

, , .

, ,

"
+1

SQL-?

  • IP-
  • SQL- .
0

Create entity classes using the wizard. This way you get the encoded connection string in app.config

0
source

All Articles