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?
 
Moti Mashiah.NET DeveloperAuthor Commented:
I solved the issue.

I have written another class which authenticate with the sql server and web.config.
0
 
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
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
Moti Mashiah.NET DeveloperAuthor Commented:
I just checked and tcp\ip is enable.
0
 
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:
solved
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.