• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 524
  • Last Modified:

Can't Attach to Database After Upgrading SQL Server

Hello Experts - I really need your help!

The issue: I upgraded from SQL Server Express to SQL Server 2008 R2 over the weekend, and now I can't connect to the project database from either Visual Web Developer or SQL Server Management Studio.

Background: I started building my first web app a few months ago, using Visual Web Developer Express and SQL Server Express. I built the database from within VWD.  This is on a stand-alone PC; no networking.  I recently discovered that in order to load the db to the commercial host, it had to be a backup (.BAK), and that I couldn't create the backup file in Express. So, I purchased a developer license of SQL Server 2008 R2, and installed it over the weekend. There were so many options in the installation process, I'm sure I messed something up, but I'm not sure where to start.

Now, when I go into VWD and view the Database Explorer, the project DB shows there but "test connection" fails. I tried modifying the connection from there, but have not had luck with either the "Select or Enter a Database Name" or "Attach a Database" options. The first doesn't show my db in the drop-down, and the second has a browse button but I can't navigate to the db file.

I suspect that if I could add the database to the list in SQL Server Management Studio, I'd then be able to connect to it from VWD.  The attached screenshot shows the error I get after clicking Attach Database --> Add...

I have no experience with SQL Server, so am looking for specific direction on what settings I need (I'm guessing from initial research things like Instance Name, Server Name, connection string, etc.), and also where to find them and where to set them so that everything talks to each other.  If I need to provide additional info here just let me know what is needed and how I find it.

Thanks in advance -- I really need to get this resolved so I can get back to coding!

Thank You! Screen Shot - SQL Mgmt Studio
2 Solutions
It sound like you do not have rights to access the specified path.
Change de directory of .mdf datafiles ("instance"\data) and try again.
Just like that.
JMS1965Author Commented:
Hello -

Thanks for your suggestion! I really apologize for my inexperience here, but if you could clarify a couple things I will give it a try ...


You have "instance" in quotes, so can you tell me how to find the instance name value?


Once I have the instance value, where do I set it?
Thanks for working with me on this!
Ramesh Babu VavillaCommented:
check the database path in the sql server properits,cheeck the image attached

change the path to you current path
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Alpesh PatelAssistant ConsultantCommented:
Please make sure the user has permission to read the folder. Files PAth is valid etc. etc
put the files into path indicated in your environment (see post #36564918)
... ,please.
JMS1965Author Commented:
OK ... we have progress!

I copied the database into the directory specified in the server properties window (thanks for the screen shot).

I can now see the database in SQL Server Management Studio.

I went back to Visual Web Developer, and was able to try enough things that I finally got the db connected there. I then worked on modifying the connection string so the app would work.  I am now stuck here.

I have three connection strings, the first for the database in question and the next two for Entity Framework models.  The first one is now working ... I can log in to the app from web browser.  But, I'm not sure what to do on the next two strings; whenever the app tries to use the Entity models, the error is "Underlying Provider Failed to Open".  Here are the connection strings:

      <add name="ApplicationServices" connectionString="Data Source=JULIESCHWALM-PC;Initial Catalog=ASPNETDB.MDF;Integrated Security=True"/>
      <add name="edmIFAapp" connectionString="metadata=res://*/App_Code.EFmodels.edmIFAapp.csdl|res://*/App_Code.EFmodels.edmIFAapp.ssdl|res://*/App_Code.EFmodels.edmIFAapp.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=JULIESCHWALM-PC;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
      <add name="edmAcctSettings" connectionString="metadata=res://*/App_Code.EFmodels.edmAcctSettings.csdl|res://*/App_Code.EFmodels.edmAcctSettings.ssdl|res://*/App_Code.EFmodels.edmAcctSettings.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=JULIESCHWALM-PC;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

Open in new window

Any ideas on this part?

What has changed is that the database is now in a different location (the path specified in the server properties), where before this change it was stored in the App_Code folder of the web app (within My Documents).

JMS1965Author Commented:

Through trial and error, I got the Entity Framework connection strings working also, by replacing:




Thanks all!
JMS1965Author Commented:
Thank you again!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now