problems connecting to SQL Server 2005

Last post 06-10-2009 6:52 AM by shahu. 18 replies.

Sort Posts:

  • problems connecting to SQL Server 2005

    06-09-2008, 11:54 AM
    • Member
      184 point Member
    • epasho
    • Member since 06-09-2008, 3:45 PM
    • Michigan
    • Posts 46

     need some help... it runs fine on localhost but when i upload yesterday on the host server i get this:

    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.

    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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

    Source Error:

    Line 5:  	Sub Application_Start(ByVal sender As [Object], ByVal e As EventArgs)
    Line 6: AddHandler SiteMap.SiteMapResolve, AddressOf Me.AppendQueryString
    Line 7: If (Roles.RoleExists("Administrators") = False) Then
    Line 8: Roles.CreateRole("Administrators")
    Line 9: End If
     

     do i need to change anything to global.asax file?

    thanks 

    Endrit Pasho

    "Intellectuals solve problems; geniuses prevent them"
    -- Albert Einstein
  • Re: problems connecting to SQL Server 2005

    06-10-2008, 4:59 PM
    • Member
      367 point Member
    • trevorkeast
    • Member since 04-25-2008, 1:49 PM
    • Posts 108

    Can we see your connection string? You shouldn't need to modify the Global.asx - looks to me as though it cant find the database. Probably a web.config issue.

    Trevor Keast

  • Re: problems connecting to SQL Server 2005

    06-11-2008, 9:17 AM
    • Member
      184 point Member
    • epasho
    • Member since 06-09-2008, 3:45 PM
    • Michigan
    • Posts 46
    Line 5:  	Sub Application_Start(ByVal sender As [Object], ByVal e As EventArgs)
    Line 6: AddHandler SiteMap.SiteMapResolve, AddressOf Me.AppendQueryString
    Line 7: If (Roles.RoleExists("Administrators") = False) Then
    Line 8: Roles.CreateRole("Administrators")
    Line 9: End If



    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) +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) +421
    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) +133
    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.RoleExists(String roleName) +482
    System.Web.Security.Roles.RoleExists(String roleName) +242
    ASP.global_asax.Application_Start(Object sender, EventArgs e) in
     
     this is after i refresh the page....
     

    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.



    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: SQL Network Interfaces, error: 26 - Error
    Locating Server/Instance Specified)



    Source Error:




    Line 194:			Using command As New SqlCommand("GetNonEmptyAlbums", connection)
    Line 195: command.CommandType = CommandType.StoredProcedure
    Line 196: connection.Open()
    Line 197: Dim list As New Generic.List(Of Album)()
    Line 198: Using reader As SqlDataReader = command.ExecuteReader
     
     
    this is the string....
    Using connection As New SqlConnection(ConfigurationManager.ConnectionStrings("Personal").ConnectionString)
    This is goodaddy hosting if you had any problems with them... 
     
     
    Thanks,Endrit 
    Endrit Pasho

    "Intellectuals solve problems; geniuses prevent them"
    -- Albert Einstein
  • Re: problems connecting to SQL Server 2005

    06-11-2008, 9:45 AM
    Answer
    • Member
      367 point Member
    • trevorkeast
    • Member since 04-25-2008, 1:49 PM
    • Posts 108

    epasho:
    Using connection As New SqlConnection(ConfigurationManager.ConnectionStrings("Personal").ConnectionString)

     

    That is not your connection string. Your connection string is in your web.config file and I'm pretty sure that is where the problem lies. Can you let me see your Web.config file? Or at least the connection strings inside that file...There may be two or more connection strings.

     

    Trevor Keast. 

  • Re: problems connecting to SQL Server 2005

    06-11-2008, 9:50 AM
    Answer
    • Member
      184 point Member
    • epasho
    • Member since 06-09-2008, 3:45 PM
    • Michigan
    • Posts 46

    <connectionStrings>
            <add name="Personal" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|Personal.mdf" providerName="System.Data.SqlClient"/>
            <remove name="LocalSqlServer"/>
            <add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf"/>
        </connectionStrings>

    thanks, endrit

     

    Endrit Pasho

    "Intellectuals solve problems; geniuses prevent them"
    -- Albert Einstein
  • Re: problems connecting to SQL Server 2005

    06-11-2008, 10:07 AM
    Answer
    • Member
      367 point Member
    • trevorkeast
    • Member since 04-25-2008, 1:49 PM
    • Posts 108

    It's not working because your connection strings are incorrect. They are not setup to work on the godaddy server. I'm not sure what all the settings are for godaddy as I don't use them myself however I can have a good guess here:

    connectionStrings>

    <

    add name="Personal" connectionString=" Server=p3swhsql-v07.shr.phx3.secureserver.net; Database=Personal; User ID=yourusername; Password=yourpassword; Trusted_Connection=False" providerName="System.Data.SqlClient"/>

    <

    remove name="LocalSqlServer"/>

    <

    add name="LocalSqlServer" connectionString=" Server=p3swhsql-v07.shr.phx3.secureserver.net; Database=ASPNETDB; User ID=yourusername; Password=yourpassword; Trusted_Connection=False" providerName="System.Data.SqlClient"/>

    </

    connectionStrings>

     

    You will need to modify the above to match your details. You need to put your username and password in there. You also need to make sure that the database names match what you have on the server.

    I just want to check - you do have your databases on the GoDaddy server right? Both of them, ASPNETDB and Personal?

     

    Anyway - at least we know why it's not working now. Let me know if you make any progress. 

     

    Trevor Keast.
     

  • Re: problems connecting to SQL Server 2005

    06-11-2008, 4:37 PM
    Answer
    • Member
      184 point Member
    • epasho
    • Member since 06-09-2008, 3:45 PM
    • Michigan
    • Posts 46

     Hello Trevor,

    I found your suggestion very supportive and as a solution to the issue. Thanks and keep up your effort! 

     

    Endrit 

    Endrit Pasho

    "Intellectuals solve problems; geniuses prevent them"
    -- Albert Einstein
  • Re: problems connecting to SQL Server 2005

    06-12-2008, 9:37 AM
    Answer
    • Member
      367 point Member
    • trevorkeast
    • Member since 04-25-2008, 1:49 PM
    • Posts 108

    I'm pleased I could help! Please mark my post as answer if it resolved your question.

    Regards,

    Trevor Keast

  • Re: problems connecting to SQL Server 2005

    06-29-2008, 5:26 AM

    hi Trevor Keast,

                          i am creating my first website and i have a database connecion in my Default.aspx  for gridview which connection is stored in web.config ,but when i access my site it shows the error.

     

    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)

     

    my web.config connections are

    <connectionStrings>

    <add name="ASPNETDBConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True;Connection Timeout=120"

    providerName="System.Data.SqlClient" />

    <add name="ASPNETDBConnectionString_news" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True;Connection Timeout=12"

    providerName="System.Data.SqlClient" />

    <add name="ASPNETDBConnectionString_test" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True;Connection Timeout=12"

    providerName="System.Data.SqlClient" />

    <add name="ASPNETDBConnectionString2_adminnews" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True;Connection Timeout=12"

    providerName="System.Data.SqlClient" />

    <add name="ASPNETDBConnectionString_gridshow" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True;Connection Timeout=12"

    providerName="System.Data.SqlClient" />

    </connectionStrings>

        

    when i was not using the Connection Timeout=12 it was not showing any error.my sitename is ouruttarakhand.com,please guide me.Thanks. i want to use built in sqlexpress ASPNETDB.MDF database

  • Re: problems connecting to SQL Server 2005

    06-29-2008, 9:39 AM
    • Member
      184 point Member
    • epasho
    • Member since 06-09-2008, 3:45 PM
    • Michigan
    • Posts 46

     u need to change the connectionString to the point to your database server and change the name attribute to whatever your are using....see previous posts. also  the usename and the passwrod

    endrit 

    Endrit Pasho

    "Intellectuals solve problems; geniuses prevent them"
    -- Albert Einstein
  • Re: problems connecting to SQL Server 2005

    06-30-2008, 12:24 AM

    hi, thanks for ur reply but now it is showing this error

     

    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)

     

    so what is the solution ,please?

  • Re: problems connecting to SQL Server 2005

    06-30-2008, 9:25 AM
    • Member
      367 point Member
    • trevorkeast
    • Member since 04-25-2008, 1:49 PM
    • Posts 108

    It still looks as though your connection string is not correct. What server are you connecting to? Is it just running on your local machine or are you trying to connect to a hosted server?

    Trevor 

  • Re: problems connecting to SQL Server 2005

    07-04-2008, 6:38 AM
    • Member
      6 point Member
    • markcus2117
    • Member since 07-04-2008, 8:27 AM
    • Posts 5

     Hi I used the post to try and solve a similiar problem of my own but it then through another error.

     

    the first error after uploading to my provider was this

     

    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)

    ine 5:  	Sub Application_Start(ByVal sender As [Object], ByVal e As EventArgs)
    Line 6: AddHandler SiteMap.SiteMapResolve, AddressOf Me.AppendQueryString
    Line 7: If (Roles.RoleExists("Administrators") = False) Then
    Line 8: Roles.CreateRole("Administrators")
    Line 9: End If
     

     

     

    I read through the posts and found one related to database names in the Web.config so I changed it from this 

     

    <connectionStrings>
            <add name="Personal" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|Personal.mdf" providerName="System.Data.SqlClient" />
            <remove name="LocalSqlServer"/>
            <add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf" />
        </connectionStrings>

     

    to This  

    <add name="Personal" connectionString=" Server=markeu.mysqlservers.xs4all.nl; Database=mark; User ID=markeu_marka; Password=xxxxxx; Trusted_Connection=False" providerName="System.Data.SqlClient"/>

    <remove name="LocalSqlServer"/>

    <add name="LocalSqlServer" connectionString=" Server=Server=markeu.mysqlservers.xs4all.nl; Database=mark; User ID=markeu_markw; Password=xxxxxx; Trusted_Connection=False" providerName="System.Data.SqlClient"/>

    </
    connectionStrings>

     

    I know the database name is "Mark" as i created the name and I know the username for Admin is Markeu_marka   and for write access is markeu_markw  both with different passwords. 

     

    Now the error I get is this

     

    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:

    Line 194:			Using command As New SqlCommand("GetNonEmptyAlbums", connection)
    Line 195: command.CommandType = CommandType.StoredProcedure
    Line 196: connection.Open()
    Line 197: Dim list As New Generic.List(Of Album)()
    Line 198: Using reader As SqlDataReader = command.ExecuteReader
     

     Can anyone help me?

     

     

     

     

  • Re: problems connecting to SQL Server 2005

    07-04-2008, 7:29 AM
    • Star
      7,715 point Star
    • jeremyh
    • Member since 01-23-2003, 12:14 PM
    • York, England
    • Posts 1,380

    Hello Markus,

    You do not tell us how you are running your site? So have you uploaded the files to your host and the moved the datbase from a local mdf to the host sql server?

    If you have did you add the membership schema to the database? Take a read of http://aspnet.4guysfromrolla.com/articles/040506-1.aspx for more info.

    And my last question this is a MS sql server "mysqlservers.xs4all.nl" and not a mysql one?

    let me know and I will try to help you more.

    Regards
    Jeremy
    If this has helped Please: Don't forget to click "Mark as Answer" on the post that helped you.
    That way future readers will know which post solved your issue.
  • Re: problems connecting to SQL Server 2005

    07-04-2008, 7:51 AM
    • Member
      6 point Member
    • markcus2117
    • Member since 07-04-2008, 8:27 AM
    • Posts 5

     Hi Jeremy.

     

    This shows how new I am to this - so yes I uploaded the files to my host - but moved the database ? I did not see that in any documentation! so I guess I have not done this 

     

    The mysqlservers.xs4all.nl is the address for the server I recieved from my provider.

    Database type: mssql
    Database naam: markeu_mark
    Database hostnaam: markeu.mssqlservers.xs4all.nl
    Database admin loginnaam: markeu_marka
    Database read-write loginnaam: markeu_markw

     

Page 1 of 2 (19 items) 1 2 Next >