Click here to Skip to main content
15,888,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to solve this error message:

network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible....
Posted
Comments
Sridhar Patnayak 6-Jan-12 23:46pm    
Can you share your code!

Check whether you allo remote connection or not.
allow remote connections
and then use

C#
<add key="con" value="Data Source=10.11.1.13;Initial Catalog=omx;Persist Security Info=True;/></pre></xml>"></add>
 
Share this answer
 
make sure your database server is on & on network.

<add key="con" value="Data Source=10.11.1.13;database=database_name;uid=userid; pwd=password;"></xml>">
 
Share this answer
 
Try out one of the following,

1)Add the sql server port to the connection string:
C#
Server=YourSQLSRVR,10000;Database=YourDatabase;User ID=User;Password=?????????

2)
1. Your SQl Browser is off
2. Protocols under SQLServer Configuration Manager > SQL Server 2005 Network Configuration > Protocols for SQL Express like TCP/IP, Named Pipes are disabled.

Resolution.

Just Start SQL Browser.
Enable the Protocols.
Restart SQL Express service.


3)your pc name\SQLEXPRESS

u copy this name and paste it in the web config file of your asp.net framework as
HTML
<connectionStrings>
<add name="this name is as your wish" connectionString="server=your pc name\\SQLEXPRESS; catalog= your database name;SSPI=true; providerName="System.Data.SqlClient" "/>
</connectionString>
this section comes under <appSettings/>

then u call this string connection in ur aspx.cs code file as
C#
// Create the Connection object.
string connectionString =
WebConfigurationManager.ConnectionStrings["this name is as your wish"].ConnectionString;
SqlConnection con = new SqlConnection(connectionString);

then u open the connection and use for your purpose and make sure that u close the connection after use

I hope this might resolve the problem
 
Share this answer
 
v2

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