0

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.

1
  • I have checked for the possibility of another connection string in my other web.config file in my project as well as machine.config and web.config under the .NetFramework 4.0 Config folder. I could not find any there. What is weird is i looked into my .NetFramework 2.0 config folder and in both web.config and machine.config this ASPNETDB connection string is specified. Is this right? I am using version 4.0 of .NetFramework. Why is it using the connection string from the 2.0 folder? Some default aspnetdb.mdf setting? How can i override this ? Commented Feb 4, 2012 at 16:53

2 Answers 2

1

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 ...
Sign up to request clarification or add additional context in comments.

Comments

1

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" />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.