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.M ySqlRolePr ovider, MySql.Web, Version=5.1.1.0, Culture=neutral, PublicKeyToken=c5687fc8896 9c44d" connectionStringName="Loca lMySqlServ er" applicationName="/" />
Source File: C:\Windows\Microsoft.NET\F ramework\v 2.0.50727\ Config\mac hine.confi g 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).
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.M
Source File: C:\Windows\Microsoft.NET\F
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).
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?
ASKER
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
You can download it from here:
http://dev.mysql.com/downloads/connector/net/5.1.html
ASKER
I found it, the new version is 5.1.2, but discovered I've already got 5.1.1 installed.
ASKER
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=fa lse" providerName="MySql.Data.M ySqlClient " />
</connectionStrings>
---
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;
</connectionStrings>
---
ASKER
I'll find out tomorrow if I have the same problem on the other computer. That should help me to isolate the problem.
ASKER
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.SqlI nternalCon nection.On Error(SqlE xception exception, Boolean breakConnection) +735043
System.Data.SqlClient.TdsP arser.Thro wException AndWarning (TdsParser StateObjec t stateObj) +188
System.Data.SqlClient.TdsP arser.Conn ect(Boolea n& 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.SqlI nternalCon nectionTds .OpenLogin Enlist(Sql Connection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +628
System.Data.SqlClient.SqlI nternalCon nectionTds ..ctor(DbC onnectionP oolIdentit y identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +170
System.Data.SqlClient.SqlC onnectionF actory.Cre ateConnect ion(DbConn ectionOpti ons options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +130
System.Data.ProviderBase.D bConnectio nFactory.C reateNonPo oledConnec tion(DbCon nection owningConnection, DbConnectionPoolGroup poolGroup) +27
System.Data.ProviderBase.D bConnectio nFactory.G etConnecti on(DbConne ction owningConnection) +47
System.Data.ProviderBase.D bConnectio nClosed.Op enConnecti on(DbConne ction outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlC onnection. Open() +111
System.Web.Management.SqlS ervices.Ge tSqlConnec tion(Strin g server, String user, String password, Boolean trusted, String connectionString) +68
[HttpException (0x80004005): Unable to connect to SQL Server database.]
System.Web.Management.SqlS ervices.Ge tSqlConnec tion(Strin g server, String user, String password, Boolean trusted, String connectionString) +124
System.Web.Management.SqlS ervices.Se tupApplica tionServic es(String server, String user, String password, Boolean trusted, String connectionString, String database, String dbFileName, SqlFeatures features, Boolean install) +86
System.Web.Management.SqlS ervices.In stall(Stri ng database, String dbFileName, String connectionString) +25
System.Web.DataAccess.SqlC onnectionH elper.Crea teMdfFile( String fullFileName, String dataDir, String connectionString) +397
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.SqlI
System.Data.SqlClient.TdsP
System.Data.SqlClient.TdsP
System.Data.SqlClient.SqlI
System.Data.SqlClient.SqlI
System.Data.SqlClient.SqlC
System.Data.ProviderBase.D
System.Data.ProviderBase.D
System.Data.ProviderBase.D
System.Data.SqlClient.SqlC
System.Web.Management.SqlS
[HttpException (0x80004005): Unable to connect to SQL Server database.]
System.Web.Management.SqlS
System.Web.Management.SqlS
System.Web.Management.SqlS
System.Web.DataAccess.SqlC
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.
Second: Can you provide an example of what you are using for a connection string?
Thanks.
ASKER
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=fa lse" providerName="MySql.Data.M ySqlClient " />
</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
<connectionStrings>
<add name="LocalMySqlServer" connectionString="data source=localhost;uid=root;
</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
ASKER
I never asked the system to use MySqlServer.
ASKER
OK, I uninstalled the MySQL .net connector and it worked. My connection string is
<connectionStrings>
<add name="Personal" connectionString="Data Source=.\SQLExpress;Integr ated Security=True;User Instance=True;AttachDBFile name=|Data Directory| Personal.m df" providerName="System.Data. SqlClient" />
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integr ated Security=True;User Instance=True;AttachDBFile name=|Data Directory| aspnetdb.m df"/>
</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.
<connectionStrings>
<add name="Personal" connectionString="Data Source=.\SQLExpress;Integr
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integr
</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.
ASKER
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!
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!
http://forums.mysql.com/read.php?38,151526,151526#msg-151526