Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

Error to connect to SQL Server...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LamSoft - 25 Jul 2007 02:25 GMT
My page is not using a database but the asp.net is trying to connect to the sql server....
I didn't see any code from stack trace is going to connect the sql server, and who call the "System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile" to raise this error... thanks.

An error has occurred while establishing a connection to the server.
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]
  System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +739123
  System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
  System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject) +685966
  System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +109
  System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +383
  System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +181
  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

Mark Fitzpatrick - 25 Jul 2007 02:35 GMT
Are you using any features such as Membership and/or personlization. Even though a page isn't using the database, something in the web.config file may be doing it. I often see an error in creating an MDF file when using the ASP.Net membership system and providing an incorrect connection string (thus forcing the membership system to try to create the mdf for itself and throwing that odd error).

Signature

Hope this helps,
Mark Fitzpatrick
Microsoft FrontPage MVP 199?-2006. 2007 and beyond

 My page is not using a database but the asp.net is trying to connect to the sql server....
 I didn't see any code from stack trace is going to connect the sql server, and who call the "System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile" to raise this error... thanks.

 An error has occurred while establishing a connection to the server.
 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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]
  System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +739123
  System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
  System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject) +685966
  System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +109
  System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +383
  System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +181
  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

LamSoft - 25 Jul 2007 02:39 GMT
I am using the Login component, FormsAuthentication, will they caused this error?
If so, what can I do? Thanks
 Are you using any features such as Membership and/or personlization. Even though a page isn't using the database, something in the web.config file may be doing it. I often see an error in creating an MDF file when using the ASP.Net membership system and providing an incorrect connection string (thus forcing the membership system to try to create the mdf for itself and throwing that odd error).

 --
 Hope this helps,
 Mark Fitzpatrick
 Microsoft FrontPage MVP 199?-2006. 2007 and beyond
   "LamSoft" <[nospam]lamsoft@lamsoft.net> wrote in message news:%232smIslzHHA.5284@TK2MSFTNGP05.phx.gbl...
   My page is not using a database but the asp.net is trying to connect to the sql server....
   I didn't see any code from stack trace is going to connect the sql server, and who call the "System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile" to raise this error... thanks.

   An error has occurred while establishing a connection to the server.
   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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]
  System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +739123
  System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
  System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject) +685966
  System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +109
  System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +383
  System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +181
  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

Juan T. Llibre - 25 Jul 2007 03:07 GMT
re:
!> I am using the Login component, FormsAuthentication, will they caused this error?

So, you *are* using a database, only you didn't know it.

Any time you have a "Login component", you also need the Membership database.

If you haven't created a Membership database,
and try to connect to a non-existent db, errors like the one you quoted occur.

Please review these links :

http://weblogs.asp.net/scottgu/archive/2006/02/24/ASP.NET-2.0-Membership_2C00_-R
oles_2C00_-Forms-Authentication_2C00_-and-Security-Resources-.aspx

and
http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx

If you have any questions after you've studied thjose, let us know.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espanol : http://asp.net.do/foros/
======================================
I am using the Login component, FormsAuthentication, will they caused this error?
If so, what can I do? Thanks
 "Mark Fitzpatrick" <markfitz@fitzme.com> wrote in message news:Otk0NwlzHHA.5476@TK2MSFTNGP03.phx.gbl...

Are you using any features such as Membership and/or personlization. Even though a page isn't using the database,
something in the web.config file may be doing it. I often see an error in creating an MDF file when using the ASP.Net
membership system and providing an incorrect connection string (thus forcing the membership system to try to create the
mdf for itself and throwing that odd error).

 --
 Hope this helps,
 Mark Fitzpatrick
 Microsoft FrontPage MVP 199?-2006. 2007 and beyond
   "LamSoft" <[nospam]lamsoft@lamsoft.net> wrote in message news:%232smIslzHHA.5284@TK2MSFTNGP05.phx.gbl...
   My page is not using a database but the asp.net is trying to connect to the sql server....

I didn't see any code from stack trace is going to connect the sql server, and who call the
"System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile" to raise this error... thanks.

   An error has occurred while establishing a connection to the server.
   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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]
  System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +739123
  System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
  System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean
ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity,
SqlConnection owningObject) +685966
  System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean
ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +109
  System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean
redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +383
  System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString
connectionOptions, String newPassword, Boolean redirectedUserInstance) +181
  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
LamSoft - 25 Jul 2007 03:31 GMT
Thanks for the information, however the control of the membership is
currently controlled by the code, not by the database... or AD..
The code is as following, if "isValidUser" returns true, the page is ok, but
if it is return false, ASP.NET will try to create the database and raise the
error....

   protected void LoginButton_Click(object sender, EventArgs e)
   {
       Session["Server_Name"] = "LocalHost";

       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();
       }
   }
   private bool isValidUser(String ServerName, String UserName, String
Password)
   {
       DirectoryEntry myDirectoryEntry;
       if (ServerName == "LocalHost")
       {
           ServerName =
System.Configuration.ConfigurationManager.AppSettings["LocalServerName"];
           myDirectoryEntry = new DirectoryEntry(@"WinNT://" + ServerName +
"/" + UserName + ",user",
               UserName, Password);
       }
       else
       {
           myDirectoryEntry = new DirectoryEntry(@"WinNT://" + ServerName +
"/" + UserName + ",user", UserName, Password);
       }
       try
       {
           Object native = myDirectoryEntry.NativeObject;
           return true;
       }
       catch (Exception ex)
       {
           FailureText.Text = ex.Message;
           return false;
       }
   }
Juan T. Llibre - 25 Jul 2007 03:58 GMT
ASP.NET ships with two membership providers: one that uses Microsoft SQL Server
as a data source and another that uses Windows Active Directory.

You appear to want to use Active Directory as a Membership Provider.

Do you have Active Directory configured as your Membership Provider in web.config ?
If not, the default membership provider is the SQL Server provider.

See :
http://msdn2.microsoft.com/en-us/library/system.web.security.activedirectorymemb
ershipprovider.aspx


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
> Thanks for the information, however the control of the membership is currently controlled by the code, not by the
> database... or AD..
[quoted text clipped - 38 lines]
>        }
>    }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.