Last post Nov 13, 2008 04:48 AM by geniousInside
Nov 08, 2008 11:26 AM|geniousInside|LINK
I am one of the newbies in asp.net. I have made a website in asp.net 2.0 with VB.Net. Site is running fine. However, I am not able to create a connection to SQLServer 2005 Express database, which I have stored in APP_Data folder. Every time I try to open
a connection, I get the following error:
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: TCP Provider,
error: 0 - No connection could be made because the target machine actively refused it.)
The connection string is (about which I m not sure if it is correct...) :-
Data Source=.\SQLEXPRESS,1433;AttachDbFilename=App_Data\ASPNETDB.MDF;Integrated Security=SSPI;User Instance=True
I have placed this connection string inside a class file, from which a connection is setup. I have enabled TCP/IP protocol in SQL server configuration. I have kept Dynamic ports disabled.
Further, one of my frends told me that Database should be kept in a location on Remote Host only at specified location, not in APP_Data folder. Is it true?
I hope I have made the problem easy to understand... Thanks a lot, folks, for your help.
Nov 10, 2008 05:34 AM|geniousInside|LINK
Is there anyone? Pleazzzzz reply..............
Nov 12, 2008 08:04 AM|Jian Kang - MSFT|LINK
From the exception, it seems that something prevents the connections or incorrect SQL Server instance name specified.
If we would like to connect the database with user instance in SQL Server Express, we have to put the database files in folder App_Data and create the connection string as below:
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ test.MDF;Integrated Security=True;User Instance=True"
For more information, please refer to the following documents:
Working with User Instances
SQL Server 2005 Express Edition User Instances
Also please refer to the KB article below to configure the SQL Server instance:
How to configure SQL Server 2005 to allow remote connections:
Nov 13, 2008 04:48 AM|geniousInside|LINK
Thanks a lot Jian, I will try as per your suggestion.