1

I published my web site to create IIS web service. but the problem is when I browse my web service by clicking on Browse *:80, it redirect me to my web-service home page which contains the list of my methods. But when I choose a method for test, it allows me to enter the inputs but when clicking the invoke button, it gives an error page. the error is:

System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file C:\Users\Nourah\WebSite1\App_Data\SBMSDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

I searched in the internet to find solution but couldn't. I tried different ways to solve it like the solution here but no result. !An attempt to attach an auto-named database for file failed in Vb.Net

Maybe it occur because I choose to Detach the database when publishing the website!! but still I have to do that because if I don't Detach the database, Visual Studio show an error and it doesn't publish the website.

I don't know how to solve this problem. please help me..

Community
  • 1
  • 1
user3287580
  • 93
  • 1
  • 9

1 Answers1

0

You need to have "User Instance=True;" in your connection string.

    <add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress or your instance    name;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory or path of filename|youfilename.mdf;"/></connectionStrings>
Jalpesh Vadgama
  • 13,653
  • 19
  • 72
  • 94