Click here to Skip to main content
15,911,789 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to connect to a database in C#

I am getting the following exception
"this failure may be caused due to default settings Sql server does not allow remote connections."

what is the reason for the exception and how to overcome it.

Please help am new to SQL...
Posted

Probably, either your connection string (fixable) or your database settings (may not be fixable).

In VS, open the Sever Explorer pane (Menu: View...Solution Explorer). Is your SQL server in the list? Is your database? If so, right click the database and select "Properties". In the properties pane, is the Connection String. Copy and paste this to your application (hopefully in the settings file) and see f that cures the problem.

If it doesn't, then you need to check if the database supports remote connections with your Database admin - since I don't know where your SQL server is, I can't help there!
 
Share this answer
 
Comments
bsb25 11-May-11 3:32am    
I have tried your first solution.THe connctn string is fine.

How to give remote access to server?i am using sql server 2005.
OriginalGriff 11-May-11 3:35am    
Before you do that, what is the code you are using to connect?
bsb25 11-May-11 3:40am    
SqlConnection con=new SqlConnection("Data Source=..//sql express;initial catalog=fdbproducts;integrated security=true;");
try
{
con.Open();
}
catch (Exception e)

{
MessageBox.show(e.message)
OriginalGriff 11-May-11 3:44am    
That doesn't look very remote! But, this is Microsoft... :laugh:
See here: http://support.microsoft.com/kb/914277 "How to configure SQL Server 2005 to allow remote connections"
"this failure may be caused due to default settings Sql server does not allow remote connections."
Your surface area configuration is not configured.

See steps for setting up Surface area configuration here..
 
Share this answer
 

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