Link to home
Start Free TrialLog in
Avatar of codequest
codequest

asked on

Anomalies in ASP.NET ConnectionStrings

I'm updating an asp.net website app that will continue to use typed datasets.  I'm using VS2013 with SQLExpress.  

As part of this work, I just completed merging the data from three databases into two:  
 using SQL Server Management Studio:
Databases = ORG, CTLS &  DATA => CTLS & DATA  (with DATA = old DATA + old ORG)

Rather than change all the connection strings references involved in the many data sets , I pointed the connection strings for ORG at the physical DATA mdf.  

The application seems to be working fine afterwards (it uses many of the tables in all three of the original DBs, so I would have failed almost immediately if it could not reach the data or the connection strings were broken).

However, there are some things I don't understand.  

1)  The first is why web.config has the "extra" connection strings shown in the code segment below.   They've been there for a long time, however, I'd like to understand why there are there.  The system fails if I remove the ones without the file paths.

<connectionStrings>
  <add name="XYZ_CTLSConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=D:\SiteFolder\App_Data\XYZ_CTLS.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
  
  <add name="XYZ_DATAConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=D:\SiteFolder\App_Data\XYZ_DATA.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
  
  <add name="XYZ_ORGConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=D:\SiteFolder\App_Data\XYZ_DATA.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
  
  
  <add name="XYZ_CTLSConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=D:\SiteFolder\App_Data\XYZ_CTLS.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
  
  <add name="XYZ_DATAConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\XYZ_DATA.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
  
  <add name="XYZ_ORGConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\XYZ_DATA.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
  
  <add name="XYZ_CTLSConnectionString2" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\XYZ_CTLS.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
  
 
</connectionStrings>

Open in new window


2) The second thing I don't understand is that when I look in VS Server Explorer I see these data connections:

XYZ_CTLSConnectionString2 (file path)
XYZ_DATA.MDF1
XYZ_ORGConnectionString1 (file path)

Open in new window


the CTLS and ORG connections open fine, and the ORG connection has all the tables I would expect from the new DATA DB.
However, when I try open or refresh the  XYZ.DATA.MDF1 connection I get this:

The attempt to attach to the database failed with the following information:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Error occurred during LocalDB instance startup: SQL Server process failed to start.
)

Open in new window


I'm happy that the application is working after this database conversion, however, I need to understand what's happening with the connectionstrings and straighten that out before I feel comfortable going forward.

Any help on this would be appreciated.

Thanks!
SOLUTION
Avatar of Johny Bravo
Johny Bravo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of codequest
codequest

ASKER

Supplemental:  When I tried johny's original suggestion, the app failed.  It looks like maybe the "extra" connection strings were added when the datasets were updated (added tables to them) after original creation.  So with the names of those connections in the data sets, they could not be removed from web.config.   Editing the names in the dataset XML seems to have eliminated the need for them in web.config.   Good learning for me, I had been reluctant to poke around in this area before.
johny_bravo1's comment was the prompt which led to my more complete procedure