3

i have connection string stored in web.config file but it is giving me the error.

<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DbProduct.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />

where is the bug in the connection string. i have stored my db DbProduct.mdf in app_data folder. i have never use SQLEXPRESS. so i need guide line. thanks

Muhammad Akhtar
  • 51,913
  • 37
  • 138
  • 191
Mou
  • 15,673
  • 43
  • 156
  • 275
  • 1
    What is "the error"? Are you intentionally using user instances? – Aaron Bertrand Aug 09 '11 at 14:38
  • we can set data directory this way `AppDomain.CurrentDomain.SetData("DataDirectory", @"c:\users\tridip.bbakolkata\documents\visual studio 2013\Projects\EFTest\EFTest");` – Mou Mar 30 '17 at 14:39

1 Answers1

4

this AttachDbFilename=|DataDirectory|\DbProduct.mdf

should be AttachDbFilename=|DataDirectory|DbProduct.mdf

You don't need to add \

Have a look at this Using connection strings from web.config in ASP.NET v2.0

Muhammad Akhtar
  • 51,913
  • 37
  • 138
  • 191