asp.net mvc

Hi Guys,

I have some issue with my default connection through web.config.

I have configured my default connection to connect my local database server and I'm getting error "Unable to connect to SQL Server database".
I have checked my server name 10 times and my database name as well, and I found all is good. also I tested from server explorer in visual studio and it works fine and connecting to the SQL server:

Here is how I'm trying to connect through web config and fail anytime:

<add name="DefaultConnection" connectionString="Data Source=localhost;Initial Catalog=Codeexample;Persist Security Info=True;User ID=sa;Password=*******;multipleactiveresultsets=True;" providerName="System.Data.SqlClient" />

Open in new window



Thanks ,
LVL 1
Moti Mashiah.NET DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
bring up sql config and enable tcpip and restart the sql server
0
Moti Mashiah.NET DeveloperAuthor Commented:
The SQL is on local machine and I can connect from any other applications.

Anyway I will try your suggestion and let you know.

Thanks ,
0
Moti Mashiah.NET DeveloperAuthor Commented:
I just checked and tcp\ip is enable.
0
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

Moti Mashiah.NET DeveloperAuthor Commented:
As I said before I can connect to SQL from anywhere else.


Thanks,
0
Moti Mashiah.NET DeveloperAuthor Commented:
After I checked again I can prove that my SQL server is working fine. I telnet to port 1433 and also connected from different solution I have and all work fine.

The issue is in my web.config in connection string I'm pretty sure.

Actually, I'm really confuse as I have two connection string in same web.config and one of them work.
 look at the config connectionstring. (the second one "CodeexampleEntities" is connecting with no issue ) the first connection is for user authentication and this is fail.

 <add name="DefaultConnection" connectionString="Data Source=localhost;Initial Catalog=Codeexample;Persist Security Info=True;User ID=sa;Password=*******;multipleactiveresultsets=True;" providerName="System.Data.SqlClient" />
  <add name="CodeexampleEntities" connectionString="metadata=res://*/Code.csdl|res://*/Code.ssdl|res://*/Code.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=localhost;initial catalog=Codeexample;persist security info=True;user id=sa;password=******;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

Open in new window

0
Moti Mashiah.NET DeveloperAuthor Commented:
I solved the issue.

I have written another class which authenticate with the sql server and web.config.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Moti Mashiah.NET DeveloperAuthor Commented:
solved
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.