An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
I am using SQL server Express 2005 on my local machine. And ASP.net 2.0 with C#.
SQL Server does not allow remote connections by default, if you want to connect remotely you will have to enable this feature. See the Screencast on my site for more information how to do this.
Jens K. Suessmeyer
http://www.sqlserver2005.de
|||Note that the OP indicates that he is running it locally... Which is odd that it would be treating a local connection as remote.
Check the protocols under the SQL configuration tool and make sure named pipes isn't disabled.
|||Yes, I did enble all the features in SQL server Express, it allws remote conenction , TCP/IP and pipes,. I searched this problem here and did all the necessary things.Still I get this error , please help . If I use my connection string from WEB.config i get following error
"............................................................................
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. ................
and if I use my connection string in code , I get above error #40.
Please help.
My connection string in code look like this :
string connstr = "server=localhost; uid=myusername; pwd=mypassword; database=dabatabasename";
Please help ASAP.
thanks
|||
Your connection string is wrong, if you are using SQLServer Express, you will have to point to the Express instance:
string connstr = @."server=localhost\SQLExpress; uid=myusername; pwd=mypassword; database=dabatabasename";
Jens K. Suessmeyer
http://www.sqlserer2005.de
|||HI,Thanks for the reply, I have modified conection String and it works ,
But I still not able to get it work from WEB.CONFIG file , Could you tell me what is the settings of WEB.CONFIG file for ASP.NET 2.0 . How can I get value of my connection String from WEB.CONFIG file.
Thanks,
|||
Could you please post the part of the connection string (if you use SQL Server authentication you can obfuscate the part with the password / username)
Jens K. Suessmeyer
http://www.sqlserver2005.de
Here is the code of my connection string:
string connstr = "server=serverName\\SQLEXPRESS; Provider=SQLOLEDB; uid=myusername; DRIVER=SQL Native Client; pwd=mypasswd; database=MyDatabaseName";
This works rightnow , if I use in each pages.
Please let me kow how can I put in WEB.config file and use it in my all ASP pages.
|||
Did you make sure that you wont need the double \ in the web-config file ?
Jens K. Suessmeyer
http://www.sqlserver2005.de
My problem is I am not able to get a value of Any varialbles of Web.config file.
I need to know how to get a value of any varialbes from WEB.CONFIG file.
Jatin.
|||
The web.config file is part of your ASP.NET application, you would be better off asking this question in a forum target at Visual Web Developer Express rather that SQL Server. The web.config file is not part of SQL Express and most the folks in this forum don't use VWD.
Mike
|||Any updates on that ?
Jens K. Suessmeyer
http://www.sqlserver2005.de
I have not posted yet on ASP.NET site. could you give me web address for that forum?
Jatin.
No comments:
Post a Comment