0

I have a problem with my first ASP.NET webforms app. I'm following a Microsoft tutorial. When I'm running the application to create the database for first time, this error appears in the browser:

Server Error in '/' Application.
Invalid value for key 'attachdbfilename'.
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.ArgumentException: Invalid value for key 'attachdbfilename'.

I'm not sure if my connection string is fine DESKTOP-6ANEE4G\MSSQLSERVER01 this is the name of my database.

Tutorial: https://learn.microsoft.com/es-es/aspnet/web-forms/overview/getting-started/getting-started-with-aspnet-45-web-forms/ui_and_navigation

<connectionStrings>
    <add name="DefaultConnection" 
         connectionString="Data Source=(DESKTOP-6ANEE4G\MSSQLSERVER01)\v11.0;Initial Catalog=aspnet-WingtipToys;Integrated Security=True" 
         providerName="System.Data.SqlClient" />
    <add name="WingtipToys" 
         connectionString="Data Source=(DESKTOP-6ANEE4G\MSSQLSERVER01)\v11.0;AttachDbFilename=|DataDirectory|\wingtiptoys.mdf;Integrated Security=True" 
         providerName="System.Data.SqlClient" />
</connectionStrings>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • See what happens if you replace `(DESKTOP-6ANEE4G\MSSQLSERVER01)` with `(LocalDB)` or maybe `(LocalDB)\MSSQLSERVER01` – Crowcoder Apr 20 '19 at 15:32
  • You can see what instances of local db you have on the command line with: `sqllocaldb.exe i` – Crowcoder Apr 20 '19 at 15:34
  • Thank you, I changed it there but I still have the same error, it will have something to do with this??: AttachDbFilename = | DataDirectory | \ wingtiptoys.mdf – L.Navarrete Apr 20 '19 at 15:52
  • 1
    Possible duplicate of [ASP .Net MVC 4, Invalid value for key 'attachdbfilename'](https://stackoverflow.com/questions/19976725/asp-net-mvc-4-invalid-value-for-key-attachdbfilename) – Mohsin Mehmood Apr 20 '19 at 18:24
  • @MohsinMehmood Thank you! I'm closer, I change the data source and now I have a new error: Directory lookup for the file "C:\Users\Lagash\source\repos\WingtipToys\WingtipToys\App_Data\wingtiptoys.mdf" failed with the operating system error 5(Access is denied.). CREATE DATABASE failed. Some file names listed could not be created. Check related errors. – L.Navarrete Apr 20 '19 at 20:18

0 Answers0