Link to home
Start Free TrialLog in
Avatar of Netlink2
Netlink2

asked on

asp.net 2 . Parser Error Message: Connection string cannot be blank

Hi, Please help me with this question, I'm sure it must be a very common question.

I'm getting this error with any Web pages I create on two development machines, both running SQL Server 2005 Express and Visual Studio 2005 (full release, wth VB install method), no IIS is installed. It works on two of my other machines with IIS installed and SQL Server 2005 installed (with Web as the install method for VS), but even then I need to install SQL Server Express on those machines (why do I need Express installed when I have a full SQL 2005 server already ?).

The error is:
Description: An error occurred during the processing of a configuration file required to service this request.
Parser Error Message: Connection string cannot be blank.
Line 157:        <add name="MySqlRoleProvider" type="MySql.Web.Security.MySqlRoleProvider, MySql.Web, Version=5.1.1.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" />
Source File: C:\Windows\Microsoft.NET\Framework\v2.0.50727\Config\machine.config    Line: 157

I've tried the asp.net configuration tool ( AspNetSqlProvider ). It says :
Could not establish a connection to the database

I've also tried changing the connectionstring in web.config with no success.

I've also tried using aspnet_regsql.exe which sees the server correctly. Note: At first that didn't work either, butI noticed that I had to use my computer name with /sqlexpress for it to work too (which I don't need to do with the full SQL server machines).
Avatar of donjon56
donjon56

I believe that this is a problem with MySQL NET Connector.  According to the following article, it was fixed in version 5.1.1

http://forums.mysql.com/read.php?38,151526,151526#msg-151526
Avatar of Netlink2

ASKER

I'm not using MySQL for these web pages, however I do have a MySQL connector on one of the machines, but not the other, so I don't think that's the problem.
ASKER CERTIFIED SOLUTION
Avatar of donjon56
donjon56

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Do both machines provide exactly the same error message?  Can I see the error message from the machine that does not have the MySQL .NET connector installed?
How do I find the download URL for 5.1.1 ?  I couldn't find it.
I think you will need to get 5.1.2 which is the current beta release

You can download it from here:
http://dev.mysql.com/downloads/connector/net/5.1.html
I found it, the new version is 5.1.2, but discovered I've already got 5.1.1 installed.
I'm kinda feeling this has nothing to do with MySQL, I'm running MS SQL for my code, with no reference to MySQL.
You error references a MySQL entry in a file that is used across ALL web projects on a single machine (machine.config).

In the thread (on post http://forums.mysql.com/read.php?38,151526,151671#msg-151671) they say it is happening even when they are not using the connector.

You could try creating a connection string in your web.config file with the name 'LocalMySqlServer'. and trying again. Something like the following should work. If that clears up you problem then it is because of the MySQL .NET Connector install program which modified your machine.config file during install.

---
<connectionStrings>
<add name="LocalMySqlServer" connectionString="data source=localhost;uid=root;pooling=false" providerName="MySql.Data.MySqlClient" />
</connectionStrings>
---


I'll find out tomorrow if I have the same problem on the other computer. That should help me to isolate the problem.
OK, here's what I get on the other machine when creating a personal web page.

Server Error in '/WebSite1' Application.
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: Shared Memory Provider, error: 40 - Could not open a connection to SQL Server)
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.

SQLExpress database file auto-creation error:

The connection string specifies a local Sql Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:

   1. If the applications App_Data directory does not already exist, the web server account must have read and write access to the applications directory. This is necessary because the web server account will automatically create the App_Data directory if it does not already exist.
   2. If the applications App_Data directory already exists, the web server account only requires read and write access to the applications App_Data directory. This is necessary because the web server account will attempt to verify that the Sql Server Express database already exists within the applications App_Data directory. Revoking read access on the App_Data directory from the web server account will prevent the provider from correctly determining if the Sql Server Express database already exists. This will cause an error when the provider attempts to create a duplicate of an already existing database. Write access is required because the web server accounts credentials are used when creating the new database.
   3. Sql Server Express must be installed on the machine.
   4. The process identity for the web server account must have a local user profile. See the readme document for details on how to create a local user profile for both machine and domain accounts.



Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SqlException (0x80131904): 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: Shared Memory Provider, error: 40 - Could not open a connection to SQL Server)]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +735043
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
   System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner, Boolean& failoverDemandDone, String host, String failoverPartner, String protocol, SqlInternalConnectionTds connHandler, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject, Boolean aliasLookup) +820
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +628
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +170
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +130
   System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +27
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +47
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
   System.Data.SqlClient.SqlConnection.Open() +111
   System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString) +68

[HttpException (0x80004005): Unable to connect to SQL Server database.]
   System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString) +124
   System.Web.Management.SqlServices.SetupApplicationServices(String server, String user, String password, Boolean trusted, String connectionString, String database, String dbFileName, SqlFeatures features, Boolean install) +86
   System.Web.Management.SqlServices.Install(String database, String dbFileName, String connectionString) +25
   System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(String fullFileName, String dataDir, String connectionString) +397
First:  Are these development machines XP?  is the XP Windows Firewall enabled (or some other firewall service installed on the development machine)?

Second: Can you provide an example of what you are using for a connection string?

Thanks.
The second machine is XP with no firewall. The first machine is Vista with firewall, but the SQL Express server is on the same machine. The connection string for the first machine is
  <connectionStrings>
    <add name="LocalMySqlServer" connectionString="data source=localhost;uid=root;pooling=false" providerName="MySql.Data.MySqlClient" />
  </connectionStrings>

I can't get the connection string for the other machine for two days now.

I just noticed that it used a MySqlServer s
I never asked the system to use MySqlServer.
OK, I uninstalled the MySQL .net connector and it worked. My connection string is
      <connectionStrings>
            <add name="Personal" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|Personal.mdf" providerName="System.Data.SqlClient"/>
            <remove name="LocalSqlServer"/>
            <add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf"/>
      </connectionStrings>

I'll award you the points now, but I still want to ask about that other computer in a few days, or would you prefer I start a new question ?.

If I could award you above excellent I would. Many thanks.
I also installed 5.1.2 and created a new web and it worked too. One down, one to go :).
I think it would be best to start a new line of questioning for the second machine and put the full error message and connection string in the main question.

I'm not as familiar with the issue on the second machine as I was with the first, because I am better with MySQL than SQL Server.  I would like to give another expert the chance to knock that issue out for you.

Having said that I will be looking for your question and will respond if no one comes up with a solution quickly.

Good Luck and Thanks!