Solved

Invalid value for key 'attachdbfilename'.

Posted on 2007-11-13
7
2,595 Views
Last Modified: 2013-11-07
Hello everyone,

I'm developing this website, basically it's asp.net pages(dev in WD2005) and a SQL DB (Express 2005), and  I stuck with this error:" Invalid value for key 'attachdbfilename'", when I try to open this one webpage.

Before I go to this page I navigate throw others that  read and write to the DB and everything it's ok.
The "webserver" is a xp professional, but I developed in an other pc with Vista, and if I run the website from the WD2005 there' s no problem with the page.

The database is in the App_Data.

Pls help me, this is driving me nuts.

Thank you


0
Comment
Question by:pinheiroa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 6

Expert Comment

by:Marcel Hopman
ID: 20276218
Post the code from your page, this is to little info to work with...
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 20276933
The problem is in your connection striing you are trying to attach to the database, when all you need to do is connect to it.  Post your connection string and everyone will be able to point out the folly of your ways :)
0
 

Author Comment

by:pinheiroa
ID: 20282518

The error changed to this:


Server Error in '/Equivale' Application.
An attempt to attach an auto-named database for file C:\Dev\Web\Estagio\BD\Horario.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
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: An attempt to attach an auto-named database for file C:\Dev\Web\Estagio\BD\Horario.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

Source Error:

Line 9:  
Line 10:
Line 11:         Dim candidato As TextBox = CType(FormView1.FindControl("TextBoxIdCandidato"), TextBox)
Line 12:         Dim data As TextBox = CType(FormView1.FindControl("data_pedidoTextBox"), TextBox)
Line 13:         Dim estado As TextBox = CType(FormView1.FindControl("textbox2"), TextBox)



and here are the web config connections strings:

      <connectionStrings>
  <add name="HorarioConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Dev\Web\Estagio\BD\Horario.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
   providerName="System.Data.SqlClient" />
  <add name="HorarioConnectionString2" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Horario.mdf;Integrated Security=True;User Instance=True"
   providerName="System.Data.SqlClient" />
  <add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Horario.mdf;Integrated Security=True;User Instance=True"
   providerName="System.Data.SqlClient" />
  <add name="HorarioConnectionString3" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Horario.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
   providerName="System.Data.SqlClient" />
  <add name="ConnectionString2" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Horario.mdf;Integrated Security=True;User Instance=True"
   providerName="System.Data.SqlClient" />
 </connectionStrings>
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 20282626
Again you are trying to attach to the database, when you should be connecting to it.  You are using the wrong connection string.  It should look like this:

connectionString="Data Source=.\SQLEXPRESS;Integrated Security=True;Connect Timeout=30;User Instance=True"

I can repeat that in Spanish, if it is not clear.
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 500 total points
ID: 20282657
Let's try that again:
connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=YourDataBaseNamegoesHere; Integrated Security=SSPI;"
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20520540
Forced accept.

Computer101
EE Admin
0

Featured Post

 Database Backup and Recovery Best Practices

Join Percona’s, Architect, Manjot Singh as he presents Database Backup and Recovery Best Practices (with a Focus on MySQL) on Thursday, July 27, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7). In the case of a failure, do you know how long it will take to restore your database?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question