Wednesday, March 7, 2012

Error Using Web Site Administration Tool

I am getting the following error using the Web Site AdministrationTool. I have created the database I want to use. Pleasehelp.

Could not establish a connection to the database.
If you have not yet created the SQL Server database, exit the Web SiteAdministration tool, use the aspnet_regsql command-line utility tocreate and configure the database, and then return to this tool to setthe provider.

The utility either is not working or I do not know how to use it.

I have SQL 2005 Express and SQL 2000. SQL 2000 is workingproperly, not sure about SQL 2005. I have been told to use SQL2000 because that is what our server is using. I am developing onmy server and when application works will port to our server.

Dee

Can you post the <connectionStrings> section in the web.config file?

I am suspecting your application is configured to use SQL Express but the service may not be enabled.

|||

This is what is in my web config:

<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.

Visual Basic options:
Set strict="true" to disallow all data type conversions
where data loss can occur.
Set explicit="true" to force declaration of all variables.
-->
<compilation debug="false" strict="false" explicit="true" />
<pages>
<namespaces>
<clear />
<add namespace="System" />
<add namespace="System.Collections" />
<add namespace="System.Collections.Specialized" />
<add namespace="System.Configuration" />
<add namespace="System.Text" />
<add namespace="System.Text.RegularExpressions" />
<add namespace="System.Web" />
<add namespace="System.Web.Caching" />
<add namespace="System.Web.SessionState" />
<add namespace="System.Web.Security" />
<add namespace="System.Web.Profile" />
<add namespace="System.Web.UI" />
<add namespace="System.Web.UI.WebControls" />
<add namespace="System.Web.UI.WebControls.WebParts" />
<add namespace="System.Web.UI.HtmlControls" />
</namespaces>
</pages>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows" />
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
</configuration>

Dee

|||

This is the error I get when trying to test a web part:

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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +735059
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


Dee

|||

OK.. I think it is taking the connection property from your machine's web.config.

Let me ask you 1 thing, do you intend to use SQL 2000 or SQL 2005 express (on your local computer) to host the aspnet DB database?

|||

I intend to use SQL 2000 on my local computer, but after I have thecode ready it will be on our server which is also using SQL 2000. Will this be a problem? Right now I need it working on my localcomputer first.

Dee

|||

OK.. this makes it clear.

This is what you need to do

1) Create the aspnetDB schema by running the regsql tool. You can use the GUI interface but I find it much easier using command line.

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe-S [DB Server Name] -U [DB login] -P [Password] -A all -d [Database name]

2) Update your site's web.config

a) Replace

<connectionStrings/>
with
<connectionStrings> <remove name="LocalSqlServer" /> <add name="LocalSqlServer" connectionString="Data Source=<DB_Server>;Integrated Security=false;Initial Catalog=<DB_Name>;User ID=<DB_User>;Password=<DB_password>" providerName="System.Data.SqlClient" /></connectionStrings>
 
PS. These information is taken from a KB articles from our Knowledge base.http://kb.discountasp.net/article.aspx?id=10413
 
|||

Tried the information above, changed DB to SQL, changed userid and password, changed database.

I got the following error:

An error has occurred. Details of the exception:
An error has occurred while establishing a connection to the server. When conne
cting 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: Named
Pipes Provider, error: 40 - Could not open a connection to SQL Server)

Unable to connect to SQL Server database.

also is there a way to do more then one database, because of this I can not even view starter kits.

Dee


|||

Are you sure the SQL 2000 server is running/ is it on the same server? What is your connection string (pls leave out the password)?

|||

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe-S [dmark] -E -A all -d [dprobationtracker]

or

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe-S [dmark] -U [Dee] -P [password] -A all -d [dprobationtracker]

SQL is running in the service manaager I can even stop the server and start it.

dee

|||

Dee,

Get rid of the "[" and "]"

ie.

aspnet_regsql.exe -S dmark -U Dee -P database_password -A all -d dprobationtracker

if your sql 2000 is on the same server, you can also use

aspnet_regsql.exe -S localhost -U Dee -P database_password -A all -d dprobationtracker

|||

I got

An error has occurred. Details of the exception:
Login failed for user 'Dee'. Reason: Not associated with a trusted SQL Server co
nnection.

Unable to connect to SQL Server database.

Don't know why Dee is my windows user login and I used the password for that.

Dee

|||

Dee,

How much do you know about MS SQL? This is becoming a SQL configuration issue rather than a ASP.NET membership issue.

Are you familiar with SQL authentication and Windows Authentication?

|||

Hi Dee,

This might because the SQL Server hasn't been enabled with SQL Authentication.

If you're logging on with a SQL Server login, you will need to create a user named "Dee" into the logins.

If you're using a Windows Authentication, you need to add your windows account to the login.

|||

I created a SQL server login using Dee, still getting the sameerror. This was working before. I tried to choose mixedmode and could not.

Dee

No comments:

Post a Comment