Why my ASPX connect to SQL Server...

L

LamSoft

I am not going to write a aspx to connect a SQL Server... but it tries to connect the SQL Server...

Some of the Code..

protected void LoginButton_Click(object sender, EventArgs e)
{
if (Request.Form["txtServerName"] == null || Request.Form["txtServerName"] == "")
{
Session["Server_Name"] = "LocalHost";
}
else
{
Session["Server_Name"] = Request.Form["txtServerName"];
}
if (isValidUser((String)Session["Server_Name"], frmLogin.UserName,frmLogin.Password))
{
Session["Server_Username"] = frmLogin.UserName;
Session["Server_Password"] = frmLogin.Password;
FormsAuthentication.RedirectFromLoginPage(frmLogin.UserName, false);
Response.End();
}
else
{
//FailureText.Text = "Access Denied!";
//Response.End();
}

}

When isValid returns true, it is ok, and redirected to another page, but when isValid return false, the error occrus then, the error message is:

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)
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.
However I did not install and not running the SQL Express Edition, I want to know why the ASPX is connecting to the SQL Server but there is no code for the SQL <-> ASP.NET Connections.

Thank you.
 
M

Mark Fitzpatrick

It wouldn't actually be in this code, it would be the settings in your web.config. I've noticed that as a default, when there are problems with a membership setting the membership runtime will try to connect to a sql server express database, since this is the default installation type.


--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
I am not going to write a aspx to connect a SQL Server... but it tries to connect the SQL Server...

Some of the Code..

protected void LoginButton_Click(object sender, EventArgs e)
{
if (Request.Form["txtServerName"] == null || Request.Form["txtServerName"] == "")
{
Session["Server_Name"] = "LocalHost";
}
else
{
Session["Server_Name"] = Request.Form["txtServerName"];
}
if (isValidUser((String)Session["Server_Name"], frmLogin.UserName,frmLogin.Password))
{
Session["Server_Username"] = frmLogin.UserName;
Session["Server_Password"] = frmLogin.Password;
FormsAuthentication.RedirectFromLoginPage(frmLogin.UserName, false);
Response.End();
}
else
{
//FailureText.Text = "Access Denied!";
//Response.End();
}

}

When isValid returns true, it is ok, and redirected to another page, but when isValid return false, the error occrus then, the error message is:

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)
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.
However I did not install and not running the SQL Express Edition, I want to know why the ASPX is connecting to the SQL Server but there is no code for the SQL <-> ASP.NET Connections.

Thank you.
 
J

Juan T. Llibre

re:
!> 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.

To fix that, please follow the instructions in this KB:

http://support.microsoft.com/kb/914277/en-us





I am not going to write a aspx to connect a SQL Server... but it tries to connect the SQL Server...

Some of the Code..

protected void LoginButton_Click(object sender, EventArgs e)
{
if (Request.Form["txtServerName"] == null || Request.Form["txtServerName"] == "")
{
Session["Server_Name"] = "LocalHost";
}
else
{
Session["Server_Name"] = Request.Form["txtServerName"];
}
if (isValidUser((String)Session["Server_Name"], frmLogin.UserName,frmLogin.Password))
{
Session["Server_Username"] = frmLogin.UserName;
Session["Server_Password"] = frmLogin.Password;
FormsAuthentication.RedirectFromLoginPage(frmLogin.UserName, false);
Response.End();
}
else
{
//FailureText.Text = "Access Denied!";
//Response.End();
}

}

When isValid returns true, it is ok, and redirected to another page, but when isValid return false,
the error occrus then, the error message is:

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)
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.
However I did not install and not running the SQL Express Edition, I want to know why the ASPX is
connecting to the SQL Server but there is no code for the SQL <-> ASP.NET Connections.

Thank you.
 
L

LamSoft

thank you very much.
I am not going to write a aspx to connect a SQL Server... but it tries to connect the SQL Server...

Some of the Code..

protected void LoginButton_Click(object sender, EventArgs e)
{
if (Request.Form["txtServerName"] == null || Request.Form["txtServerName"] == "")
{
Session["Server_Name"] = "LocalHost";
}
else
{
Session["Server_Name"] = Request.Form["txtServerName"];
}
if (isValidUser((String)Session["Server_Name"], frmLogin.UserName,frmLogin.Password))
{
Session["Server_Username"] = frmLogin.UserName;
Session["Server_Password"] = frmLogin.Password;
FormsAuthentication.RedirectFromLoginPage(frmLogin.UserName, false);
Response.End();
}
else
{
//FailureText.Text = "Access Denied!";
//Response.End();
}

}

When isValid returns true, it is ok, and redirected to another page, but when isValid return false, the error occrus then, the error message is:

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)
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.
However I did not install and not running the SQL Express Edition, I want to know why the ASPX is connecting to the SQL Server but there is no code for the SQL <-> ASP.NET Connections.

Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top