Marius Vasile

Marius Vasile

  • 586
  • 1.9k
  • 151.1k

Error in adding second database to web config

Jan 12 2025 1:54 PM

I am trying to use 2 databses in an application. Error is

Cannot attach the file 'D:\Documents\_VSC\ASP.NET\HazInfoSM\App_Data\evaris_rosql.mdf' as database 'evaris_rosql.mdf'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Cannot attach the file 'D:\Documents\_VSC\ASP.NET\HazInfoSM\App_Data\evaris_rosql.mdf' as database 'evaris_rosql.mdf'.

 

web config rows

<connectionStrings>
  <add name="ConnString" 
       connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\HazInfoSM_SQL.mdf;Database=HazInfoSM_SQL.mdf;Integrated Security=True" 
       providerName="System.Data.SqlClient"/>
  <add name="HazInfoSM.Properties.Settings.ConnectionString" 
       connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=&quot;D:\Documents\_VSC\HazInfoSM\App_Data\HazInfoSM_SQL.mdf&quot;;Initial Catalog=HazInfoSM_SQL.mdf;Integrated Security=True"/>

  <add name="ConnStringEvaris" 
       connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\evaris_rosql.mdf;Database=evaris_rosql.mdf;Integrated Security=True"
       providerName="System.Data.SqlClient" />
  <add name="Evaris.Properties.Settings.ConnectionString" 
       connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=&quot;D:\Documents\_VSC\Evaris\App_Data\evaris_rosql.mdf&quot;;Initial Catalog=evaris_rosql.mdf;Integrated Security=True" />
</connectionStrings>

what am I doing wrong?