I am attempting to connect to a database that has been uploaded to my server from my webpages on the server. This is the connection string that is currently used:
connectionString
="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Restaurants.mdf;Integrated Security=True;User Instance=True"When attempting to connect to the database I receive this error message:
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I realize that I cannot make a remote connection using SQL Server 2005 Express Edition, but cannot find the proper connection string for it to connect to the uploaded database.
Accessing the database doesn't require a log on by the user as all the information is public.
The authentication mode in the web.config file is set to "Forms".
If there is any other information required so that this problem can be solved, please ask for it.
Thank you in advance,
Me
An error has occurred while establishing aconnection to the server. When connecting to SQL Server 2005, thisfailure may be caused by the fact that under the default settings SQLServer does not allow remote connections. (provider: SQL NetworkInterfaces, error: 26 - Error Locating Server/Instance Specified)
 1.
Cause: Server not configured for remote connections.
The error is telling us that your server has not been configured to allow remote connections. If your SQL Server has not been configured to allow remote connections, then configure your SQL Server.
Fix:
SQL Server 2005 Open SQL Server Configuration Manager. Select "SQL Server 2005 Network Configuration | Protocols for MSSQLSERVER" then enable the protocols you need.
2.
Cause: ASP.Net 2.0 Providers are trying to pull from the server's (nonexistent) Providers database.
Bydefault the machine.config file is trying to pull the Providerinformation from a SQLExpress database using an invalid connectionstring named "LocalSQLServer". Many web servers will not haveSQLExpress enabled, and will not have this value set to a valid SQLServer database that is of use to you. In a shared hosting environment,this is especially true, as it would be expected that you would wantyour Provider information stored in your database and not some singledatabase shared by the other users of that web server.
Fix:
Since youprobably cannot access the machine.config file, you need to overridethe Provider settings in your web.config file, and set the connectionstring name to your connection string name. The following code comesfrom the machine.config file and has been modified to first remove eachprovider before adding the provider.
Add the following code to your web.config file just under the "<system.web>" tag.
Make sure to replace the 3 occurrences of connectionStringName="LocalSQLServer" with your connection string name.
1 <membership>23 <providers>45 <remove name="AspNetSqlMembershipProvider" />67 <add name="AspNetSqlMembershipProvider"89 type="System.Web.Security.SqlMembershipProvider,1011 System.Web, Version=2.0.0.0, Culture=neutral,1213 PublicKeyToken=b03f5f7f11d50a3a"1415 connectionStringName="LocalSQLServer"1617 enablePasswordRetrieval="false"1819 enablePasswordReset="true"2021 requiresQuestionAndAnswer="true"2223 applicationName="/"2425 requiresUniqueEmail="false"2627 passwordFormat="Hashed"2829 maxInvalidPasswordAttempts="5"3031 minRequiredPasswordLength="7"3233 minRequiredNonalphanumericCharacters="1"3435 passwordAttemptWindow="10"3637 passwordStrengthRegularExpression="" />3839 </providers>4041 </membership>4243 <profile>4445 <providers>4647 <remove name="AspNetSqlProfileProvider" />4849 <add name="AspNetSqlProfileProvider"5051 connectionStringName="LocalSQLServer"5253 applicationName="/"5455 type="System.Web.Profile.SqlProfileProvider,5657 System.Web, Version=2.0.0.0, Culture=neutral,5859 PublicKeyToken=b03f5f7f11d50a3a" />6061 </providers>6263 </profile>6465 <roleManager>6667 <providers>6869 <remove name="AspNetSqlRoleProvider" />7071 <add name="AspNetSqlRoleProvider"7273 connectionStringName="LocalSQLServer"7475 applicationName="/"7677 type="System.Web.Security.SqlRoleProvider,7879 System.Web, Version=2.0.0.0, Culture=neutral,8081 PublicKeyToken=b03f5f7f11d50a3a" />8283 </providers>8485 </roleManager>
Your database must be configured for the ASP.Net 2.0 Providers. This article assumes that you have already configured your database to use ASP.Net 2.0 Providers
http://www.aquesthosting.com/HowTo/Sql2005/SQLError26.aspx
 
No comments:
Post a Comment