-1

Actually i get a project from another pc and it has a database using local db having database with visual studio. before that i always used sql server for database. so i got stuck in it.

<add name="FZDatabase" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Talha\Desktop\Fashionzonefyp\Fashionzonefyp\App_DataFZDATABASE.MDF;Integrated Security=True" providerName="System.Data.SqlClient" />

here is the connection string. help as a totally new comer. any further suggestions and guidlines are also wellcomed... :)

junaid
  • 93
  • 1
  • 1
  • 8
  • any error message or what exactly is the question? – Bave Sep 30 '17 at 10:57
  • An attempt to attach an auto-named database for file C:\Users\Talha\Desktop\Fashionzonefyp\Fashionzonefyp\App_DataFZDATABASE.MDF failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. – junaid Sep 30 '17 at 11:01
  • Change "AttachDbFilename" to "Initial Catalog" – Bave Sep 30 '17 at 11:06
  • Cannot open database "C:\Users\Talha\Desktop\Fashionzonefyp\Fashionzonefyp\App_DataFZDATABASE.MDF" requested by the login. The login failed. – junaid Sep 30 '17 at 11:10
  • In that case, make sure that the service running your application has access to the file. – Bave Sep 30 '17 at 11:11
  • now this was the main error i was facing at first. in server explorer there is always a red cross with db name. and upon cliking on it, it shows same error. – junaid Sep 30 '17 at 11:11
  • how to check access...? – junaid Sep 30 '17 at 11:13
  • Welcome to Stack Overflow. See https://stackoverflow.com/help/how-to-ask. The best advice is to remember that people are taking their time to answer you, and the intent of Stack Overflow is to help others with the same question. Please take the time to use proper punctuation and capitalization. Also, don't post the entire error message in the title. Instead, summarize the problem like "Error opening local SQL database" then list the error text in the message. Lastly, don't add critical details to the comments. Instead, edit and improve the question with more details. – C Perkins Oct 21 '17 at 01:46

2 Answers2

0

Try this:

<add name="FZDatabase" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=C:\Users\Talha\Desktop\Fashionzonefyp\Fashionzonefyp\App_DataFZDATABASE.MDF;Integrated Security=True" providerName="System.Data.SqlClient" />
Bave
  • 235
  • 1
  • 6
0

Actually there was a problem with my db name in connection string. and secondly my db was not in the directory of local db's which is by default (C:\Users\"Your pc name"\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB). thanks for help. :)

junaid
  • 93
  • 1
  • 1
  • 8