Reputation: 41
Before I begin I would like to say I have already checked thoroughly at www.connectionstrings.com and looked at all possible threads at this forum for an answer.
Right now my connection string is like this:
<add name="LocalSqlServer"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient"/>
Its working, but I can only access it in my App_Data folder
I want to access this database from the SQL SSMS, therefore I have tried changing it like this:
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;
Database=AspNetDb;InitialCatalog=ASPNETDB; User Id=kaneXtreme;Password=password123!;User Instance=true" providerName="System.Data.SqlClient"/>
I have also tried this
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Database=AspNetDb;
Initial Catalog=ASPNETDB; User Id=kaneXtreme;Password=password123!" providerName="System.Data.SqlClient" />
Both of which I have tried changing is resulting in this Configuration error when I open up localhost:
The entry
LocalSqlServer
has already been added.
Advice please.
Upvotes: 0
Views: 2744
Reputation: 11
If your using a username and password I think you need to change Integrated Security=SSPI
to Integrated Security=True
eg.
<add name="LocalSqlServer" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=ASPNETDB;User id=kaneXtreme password=password123!;Integrated Security=True;" providerName="System.Data.SqlClient" />
Upvotes: 1
Reputation: 11
You could try to clear your connection strings before adding the first one. By default, there is a "hidden" LocalSqlServer connection string in your machine.config
<connectionStrings>
<clear/>
<add name="LocalSqlServer" and-so-on-and-so-forth ...
Upvotes: 1