fails to connect to mySQL database, from the internet

Last post 08-24-2008 9:05 PM by megetron. 3 replies.

Sort Posts:

  • fails to connect to mySQL database, from the internet

    08-16-2008, 5:53 AM
    • Member
      393 point Member
    • megetron
    • Member since 03-13-2006, 5:38 AM
    • Posts 554

    Hello,

    I am using localmachine to develop ASP.NET + MYSQL application. it works good, I have publish the website using IIS, and I browse locally to application (http://localhost/myApp) , the web application works good, and connected successfully to mySQL database.

     problem starts when I try to login from my computer using the internet IP (http://12.45.230.56/myApp) -
    At start I can see the web site, and it looks good, but when I am trying to login to website, which means connect the database,  I recieve error. I added every permission I could think of, but still the annoying error is there. do you have suggestions?

    Server Error in '/knockout' 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: Named Pipes 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.

    Exception Details: System.Data.SqlClient.SqlException: 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
       System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +800131
       System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186
       System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject) +737554
       System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +114
       System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +381
       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) +173
       System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +357
       System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +30
       System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424
       System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
       System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +494
       System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
       System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
       System.Data.SqlClient.SqlConnection.Open() +111
       System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) +84
       System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +197
       System.Web.Security.SqlRoleProvider.GetRolesForUser(String username) +771
       System.Web.Security.RolePrincipal.IsInRole(String role) +272
       System.Web.SiteMapProvider.IsAccessibleToUser(HttpContext context, SiteMapNode node) +194
       System.Web.SiteMapNode.IsAccessibleToUser(HttpContext context) +14
       System.Web.StaticSiteMapProvider.GetChildNodes(SiteMapNode node) +348
       System.Web.SiteMapNode.get_ChildNodes() +23
       System.Web.UI.WebControls.SiteMapDataSource.GetNodes() +363
       System.Web.UI.WebControls.SiteMapDataSource.GetTreeView(String viewPath) +32
       System.Web.UI.WebControls.SiteMapDataSource.GetHierarchicalView(String viewPath) +29
       System.Web.UI.HierarchicalDataSourceControl.System.Web.UI.IHierarchicalDataSource.GetHierarchicalView(String viewPath) +7
       System.Web.UI.WebControls.HierarchicalDataBoundControl.GetData(String viewPath) +22
       System.Web.UI.WebControls.TreeView.DataBindNode(TreeNode node) +73
       System.Web.UI.WebControls.TreeView.PerformDataBinding() +305
       System.Web.UI.WebControls.HierarchicalDataBoundControl.PerformSelect() +82
       System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
       System.Web.UI.WebControls.TreeView.DataBind() +4
       System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
       System.Web.UI.WebControls.TreeView.OnPreRender(EventArgs e) +43
       System.Web.UI.Control.PreRenderRecursiveInternal() +86
       System.Web.UI.Control.PreRenderRecursiveInternal() +170
       System.Web.UI.Control.PreRenderRecursiveInternal() +170
       System.Web.UI.Control.PreRenderRecursiveInternal() +170
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041
    

  • Re: fails to connect to mySQL database, from the internet

    08-16-2008, 10:00 AM
    Answer
    • All-Star
      21,648 point All-Star
    • gunteman
    • Member since 07-11-2007, 12:57 PM
    • Norrköping, Sweden
    • Posts 3,177

     You seem to be using a SqlRoleProvider, which is for SQL Server.

    -- "Mark As Answer" if my reply helped you --
  • Re: fails to connect to mySQL database, from the internet

    08-16-2008, 10:10 AM
    • Member
      393 point Member
    • megetron
    • Member since 03-13-2006, 5:38 AM
    • Posts 554

    I am using mySQLRole provider. can you please see my web.config to verify?

    and still, there is no reason why this working good from my localhost, and not from the internet...
    Here is my web.config file. take a look please.

     

    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
      <configSections>
        <section name="KnockOut" type="MB.KnockOut.KnockOutSection, __code"/>
        <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
            <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
              <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
              <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
              <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
              <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
            </sectionGroup>
          </sectionGroup>
        </sectionGroup>
      </configSections>
    
    
      <connectionStrings>
        <remove name="ClubSiteDB"/>
        <add name="ClubSiteDB" connectionString="server=localhost;database=knockout_dbo;user id=xx;pwd=xxx; connection timeout=60" providerName="MySql.Data.MySqlClient" />
        <add name="ConnectionString" connectionString="server=localhost;database=knockout_dbo;user id=xx;pwd=xxx; connection timeout=60" providerName="MySql.Data.MySqlClient"/>
      </connectionStrings>
      <system.web>
        
    
    
        <roleManager enabled="true" />
        <machineKey validationKey="287C5D125D6B7E7223E1F719E3D58D17BB967703017E1BBE28618FAC6C4501E910C7E59800B5D4C2EDD5B0ED98874A3E952D60BAF260D9D374A74C76CB741803" decryptionKey="5C1D8BD9DF3E1B4E1D01132F234266616E0D5EF772FE80AB" validation="SHA1"/>
        <!-- …other configuration settings -->
        <httpHandlers>
          <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>
    			<remove verb="*" path="*.asmx"/>
    			<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    			<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    			<add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></httpHandlers>
    		<membership defaultProvider="MySqlMembershipProvider">
    			<providers>
            <remove name="MySqlMembershipProvider"/>
    				<add name="MySqlMembershipProvider" type="MySqlProviders.MySqlMembershipProvider" connectionStringName="ClubSiteDB" enablePasswordRetrieval="true" enablePasswordReset="true" requiresUniqueEmail="false" requiresQuestionAndAnswer="false" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" applicationName="knockout" hashAlgorithmType="none" passwordFormat="Encrypted"/>
    			</providers>
    		</membership>
    		<authentication mode="Forms"/>
    		<anonymousIdentification enabled="true"/>
    		<siteMap defaultProvider="XmlSiteMapProvider1" enabled="true">
    			<providers>
    				<add name="XmlSiteMapProvider1" description="Default SiteMap provider." type="System.Web.XmlSiteMapProvider " siteMapFile="Web.sitemap" securityTrimmingEnabled="true"/>
    			</providers>
    		</siteMap>
    		<profile enabled="true" defaultProvider="MySqlProfileProvider">
    			<providers>
    				<add name="MySqlProfileProvider" type="MySqlProviders.MySqlProfileProvider" connectionStringName="ClubSiteDB" applicationName="CLUBKIT" description="Stores and retrieves profile data from an PersonalWebsiteTest database."/>
    			</providers>
    			<properties>
    				<add name="Language" type="int"/>
    				<add name="Region" type="int"/>
            <add name="Country" type="int"/>
    				<add name="Logo" type="string"/>
    				<add name="URL" type="string"/>
    				<add name="GymName" type="string"/>
    				<group name="Preferences">
    					<add name="Theme" type="String" allowAnonymous="true"/>
    					<add name="Culture" type="String" defaultValue="he-IL"/>
    				</group>
    			</properties>
    		</profile>
    		<compilation debug="true">
    			<buildProviders>
    				<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    			</buildProviders>
    			<assemblies>
    				<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    				<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    				<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    				<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    				<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    				<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    				<add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></assemblies></compilation>
    		<customErrors defaultRedirect="~/Error.aspx" mode="Off" />
        <pages enableEventValidation="false" viewStateEncryptionMode="Never"  />
    		<httpModules>
    			<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></httpModules></system.web>
    
      <system.net>
        <mailSettings>
          <smtp from="xx@xx.net">
            <network host="mail.xx.net" port="25" userName="121@xxx.net" password="1212" defaultCredentials="true" />
          </smtp>
          
        </mailSettings>
      </system.net>
    
      <system.codedom>
    			<compilers>
    				<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
    					<providerOption name="CompilerVersion" value="v3.5"/>
    					<providerOption name="WarnAsError" value="false"/></compiler>
    				<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
    					<providerOption name="CompilerVersion" value="v3.5"/>
    					<providerOption name="OptionInfer" value="true"/>
    					<providerOption name="WarnAsError" value="false"/></compiler></compilers></system.codedom>
    	<system.webServer>
    			<validation validateIntegratedModeConfiguration="false"/>
    		<modules>
    			<remove name="ScriptModule"/>
    			<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></modules>
    		<handlers>
    			<remove name="WebServiceHandlerFactory-Integrated"/>
    			<remove name="ScriptHandlerFactory"/>
    			<remove name="ScriptHandlerFactoryAppServices"/>
    			<remove name="ScriptResource"/>
    			<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    			<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    			<add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></handlers></system.webServer>
    	<runtime>
    		<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    			<dependentAssembly>
    				<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
    				<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly>
    			<dependentAssembly>
    				<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
    				<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly></assemblyBinding></runtime>
    
    
    
      <location path="forum_manage.aspx" >
        <system.web>
          <authorization>
            <allow roles="Administrators"/>
            <deny users="*"/>
          </authorization>
        </system.web>
      </location>
      <location path="forum_editpost.aspx">
        <system.web>
          <authorization>
            <allow roles="Administrators"/>
            <deny users="*"/>
          </authorization>
        </system.web>
      </location>
      <location path="forum_addpost.aspx">
        <system.web>
          <authorization>
            <deny users="?"/>
          </authorization>
        </system.web>
      </location>
      <location path="Join.aspx">
        <system.web>
          <authorization>
            <allow users="?"/>
            <deny users="*"/>
          </authorization>
        </system.web>
      </location>
      <location path="admin">
        <system.web>
          <authorization>
            <allow roles="Administrators"/>
            <deny users="*"/>
          </authorization>
        </system.web>
      </location>
      <location path="in">
        <system.web>
          <authorization>
            <allow roles="Managers"/>
            <deny users="*"/>
          </authorization>
        </system.web>
      </location>
    
    </configuration>
    
     
  • Re: fails to connect to mySQL database, from the internet

    08-24-2008, 9:05 PM
    • Member
      393 point Member
    • megetron
    • Member since 03-13-2006, 5:38 AM
    • Posts 554

     

    thanks, that was it:)
Page 1 of 1 (4 items)