Click here to Skip to main content
15,120,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 2 connection strings in the webconfig file as below
C#
<connectionstrings>
    <add name="ApplicationServices" connectionstring="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providername="System.Data.SqlClient" />
   <add name="connection1" connectionstring=" data source= abcd-PC;Database=testdata;User ID=sa;Password=abcdef" />
 <add name="connection2" connectionstring="metadata=res://*/TestModel.csdl|res://*/TestModel.ssdl|res://*/TestModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source= abcd-PC;Initial Catalog=testdata;Persist Security Info=True;User ID=sa;Password=abcdef;MultipleActiveResultSets=True"">
     providerName="System.Data.EntityClient" /> </add></connectionstrings>

Am able to connect to the database in my local database,but the same thing after i publish and hosted in the server,not able to connect to the database.am getting an error as
Fetch Error:A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)


Kindly help
Posted
Updated 28-Aug-12 4:08am
v5
Comments
Prabhakaran Soundarapandian 28-Aug-12 0:53am
   
can you post your connection string the one you are using...
Kuthuparakkal 28-Aug-12 0:54am
   
can you post both conn strings ...
Mydsh 28-Aug-12 1:04am
   
webconfig is as follows:

connectionStrings>
add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"

add name="Connection1" connectionString=" data source= testComp;Database=Testdata;User ID=sa;Password=abcdef"

add name="Connection2" connectionString="metadata=res://*/testModel.csdl|res://*/testModel.ssdl|res://*/testModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source= testComp;Initial Catalog=Testdata;Persist Security Info=True;User ID=sa;Password=abcdef;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient"
connectionStrings

providerName="System.Data.EntityClient"
Improve solution Permalink |
Posted 1 sec ago
Mydsh223
Mydsh 28-Aug-12 1:07am
   
Am using both connection strings in my application,its working fine locally,but not in server

Hi ,
It seems your problem you can't log-in using Sql authentication make sure you enable it http://kbase.gfi.com/showarticle.asp?id=KBID002804[^]
then Go to your SQL Server Configuration Tools open SQL Server Configuration Manager make sure
Shared Memory = enabled <br />
Tcp/ip = Enabled <br />
Named pipes =Enabled<br />
Via =Enabled 

Then restart Sql server Services
After doing this make your connection string See this http://www.connectionstrings.com/sql-server-2008[^]

Hope it helps
Best Regards
M.Mitwalli
   
Comments
Mydsh 28-Aug-12 1:27am
   
I tried connecting locally its not working.and also made changes in the server but still it is not connecting
Mydsh 28-Aug-12 1:27am
   
enabled all,but not working
Mohamed Mitwalli 28-Aug-12 1:40am
   
Restart the Services from SQL Server Configuration Manager and after this try to connect using Then Create New Text Document.txt Change the Extension to New Text Document.UDL Select your provider Click next Then Enter your server Name or select it from combo-box select SQL server authentication Supply your user name and password Click Test connection if it Succeeded open the file with notepad Copy your connection string and past it in Webconfig hope it help this time
data source=.\SQLEXPRESS
use IP address here
eg. data source=111.111.11.111 -> it is example, put your pc's IP address there
sql is enable to find connection using 'name' (name - pipe) error so, it can be happen use ip address there

Happy Coding!
:)
   
v2
Comments
Mydsh 28-Aug-12 1:13am
   
i tried adding the ip address,but still it not working
Aarti Meswania 28-Aug-12 1:19am
   
are you connecting locally or remotely?
Mydsh 28-Aug-12 1:14am
   
am getting this error
Fetch Error:A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
once verify Your Data Source Name in SQL SERVER and Give That Data Source Name. Some Times we Will not have \SQLEXPRESS so verify your data Source Name.
   
Comments
Mydsh 28-Aug-12 6:46am
   
Tried with that too,bit its not working for the second connection string
hi
Once check out the sql server 2008 r2 is working or not in client machine
then u can check the configuration tools as specified above

If not u need to delete SqlServer and must install a new copy
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900