Friday, March 23, 2012

Problems connecting to SQLServer Express in Plesk Server

My hosting provider use Plesk to sell space over the internet and said to me that SQLServer Express is installed on the server. I always get an stupid error trying to connect to the SQLExpress Database in my App_Data folder.

I use the connection string:
* data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|Exam
pleDB.mdf;User Instance=true
With this connection string I get the error saying that server does not alow remote connection

*data source=localhost\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|Exam
pleDB.mdf;User Instance=true

With this connection string I get the error:
Invalid value for key 'attachdbfilename'

I get the same message if I put anything in the AttachDBFileName. Why the .NET does not find the database?

tkx in advance
Paulo Aboim Pinto
Odivelas - Portugal

By default SQL Express doesn't allow remote connections, you have to configure it before you connect to the SQL service from remote. Take a look at this article for more information:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277

And you'd better usemachinename\SQLEXPRESS as Data Source in your connection string, as localhost\SQLEXPRESS doesn't work in some case.

No comments:

Post a Comment