What version of SQL server do I need when I open a Visual Studio 2010 solution with Visual Studio 2012?

StackOverflow https://stackoverflow.com/questions/17878022

سؤال

When I open a visual studio 2010 solution with visual studio 2012 I get the following message:

SQL Server Express and LocalDB

In the Web.config file I changed the connectionstring

from:

connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename
=|DataDirectory|\databaseName.mdf;Integrated Security=True;User Instance=True"

to:

connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename
=|DataDirectory|\databaseName.mdf;Integrated Security=True"

I can't connect with the database and when I run the application I still get an error message:

An attempt to attach an auto-named database for file (FILE) failed. 
A database with the same name exists, or specified file cannot be opened, 
or it is located on UNC share.

The attempt to attach to the database failed with the following information: 
Failed to generate a user instance of SQL Server due to a failure in starting 
the process for the user instance. The connection will be closed.
هل كانت مفيدة؟

المحلول 2

I have been able to connect to my database, but I still get an error message.

  • In server explorer (view > server explorer) click on the connect to database button.
  • Data Source: Microsoft SQL Server (SqlClient)
  • Server Name: (LocalDB)\v11.0
  • Attach a database file: path to mdf file
  • Test Connection
  • OK (if test connection succeeded)

After all these steps I have the green icon on my database icon in Server Explorer.

Now you can right click on database and choose properties, then you select the connectionstring and paste it in the Webconfig file.

When I press F5 on my Default.aspx file, I still get the error message:

Sql exception was unhandled by user code

An attempt to attach an auto-named database for file C:\(path to file) failed. 
A database with the same name exists, or specified file cannot be opened, 
or it is located on UNC share.

I get the error message in the file CategoriesBLL.cs at the line

return Adapter.GetCategories();

نصائح أخرى

Just double click on the solution of your project. And convert the project automatically.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top