Posted on: 3/18/2014 8:48:37 PM | Views : 422

Hi,
   I have two questions.
1.   I m not able to find "service based databse" (mdf) file in Add--> New Item--> Data in WebApplication project, but it is coming fine in ClassLib project.
2. I created mdf file in ClassLib project and given connectionstring as below in ClassLib app.config
private string cnstr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\tblCustomer.mdf;Integrated Security=True;User Instance=True";
but while running the application, code is looking for .mdf in app_data folder. How to solve this? I dont want to give hard-coded path for connectionstring, it should be relative.

This is the error I m getting
An attempt to attach an auto-named database for file D:\EmployeeDetails\EmployeeDetails\EmployeeDetails\App_Data\tblCustomer.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.< ...

Go to the complete details ...