cannot connect to SQl server

Discussion in 'Databases' started by jorge1, Mar 10, 2014.

  1. Hi,

    my application uses a database created under a local SQL 2005 Express server. Locally it works being accessed by my web-site written in Visual Web Developer 2008 of VS 2008 3.5 SP1.

    I take the connecting string from the ControlPanel, (substituting the ***** with my FTP server password) and put it in the web.config file of my application:

    <connectionStrings>
    <add name="connectToASPNETDB"
    connectionString="Data Source=tcp:s07.Winhost.com;Initial Catalog=DB_72538_3don;User ID=DB_72538_3don_user;Password=*****;Integrated Security=False;"
    providerName="System.Data.SqlClient" />
    </connectionStrings>

    Then, I uploaded (via ftp) the pages of this site (www.3Don.net.br hosted by Winhost) and for the database I followed the knowledge base article (http://support.Winhost.com/KB/a1049/how-to-transfer-your-local-sql-database-to-Winhost.aspx).

    Pages which do not use the database seem to work, but pages which need the database respond with the following error:

    ------------------------------
    Server Error in '/' Application.
    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to 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: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

    Source Error:

    Line 389: cmdString = "SELECT * FROM material WHERE material='" & material & "'"
    Line 390: cmd = New SqlCommand(cmdString, conn)
    Line 391: conn.Open()
    Line 392: myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
    Line 393: While myReader.Read()

    --------------------------

    The browser marks Line 391: conn.Open() in red.

    I chose "MS SQL 2008 R2" for the database server. This should be ok for the SQL 2005 database, shouldn't it?

    What, please, is wrong???????

    Thank you.
     
    Last edited by a moderator: Oct 14, 2015
  2. Elshadriel

    Elshadriel Winhost Staff

    The password is not your FTP password. The password is your database password. Here are instructions on how to change your database password if you have forgotten it:

    1) Log into the Winhost Control Panel at https://cp.Winhost.com
    2) Click on the Sites tab.
    3) Click on the Manage link next to the site you want to manage.
    4) Click on the MS SQL Manager button.
    5) Click on the Manage link next to the database you want to manage.
    6) Click on the Edit link next to the database password.
     
    Last edited by a moderator: Oct 14, 2015
    Michael likes this.
  3. Elshadriel,

    thanks for response.

    ok, I understand. But these two passwords are the same in my case. To be sure I redefined my database password again.
    Continue the same error (see above).

    Today I repeated all the following steps (following http://support.Winhost.com/KB/a1049/how-to-transfer-your-local-sql-database-to-Winhost.aspx):
    -- generate again a .BAK file for my database: I use MS SQL Server Management Studio Express 2005
    -- upload of this .BAK file to the App_Data directory (where, at my local machine, are the .MDF and .LOG files. To your server, I did not upload these two files.)
    -- realize the restore backup process with the Control panel tool

    Continue the same error (see above). The (above cited) error you can see @ http://www.3don.net.br/Default.aspx

    I reviewed also my web.config file (*** stands for my database(! :=) password):

    <connectionStrings>
    <add name="connectToASPNETDB"
    connectionString="Data Source=tcp:s07.Winhost.com;Initial Catalog=DB_72538_3don;
    User ID=DB_72538_3don_user;Password=***;Integrated Security=False;"
    providerName="System.Data.SqlClient" />
    </connectionStrings>


    Questions:
    1. the User ID-parameter has a blank between "User" and "ID", hasn't it?!
    2. case-sensivity: my password has capital letters, so I used capital letters. ok?!
    3. The only adaptation for databases working under Server Express to work under the complete Server is done in the connection string?
    Thank you for any help.

    Jurgen
     
    Last edited by a moderator: Oct 14, 2015
  4. Elshadriel

    Elshadriel Winhost Staff

    1) Try taking the "tcp:" out. It shouldn't cause a problem, but some customers have reported that it fixed the problem for whatever reason.
    2) Do you have an active SQL Server Express database connection string? If so, you need to comment it out. We don't support SQL Server Express.
     
    Michael likes this.
  5. Elshadriel,

    thanks for response.

    I deleted the "tcp:" from the connection string in my web.config file, uploaded the new web.config file to the Winhost server and nothing changed - the same error as above.

    Yes, my SQL Server Express database connection string is commented out (with <!-- -->)

    I annexed my web.config file (I replaced my password by ****, and annexed a .txt extension to 'web.config', the rest is original). If you could do a look....

    Thank you

    Jurgen
     

    Attached Files:

    Last edited by a moderator: Oct 14, 2015
  6. Elshadriel

    Elshadriel Winhost Staff

    Ok, it might be your Membership provider. You have this:

    connectionStringName="LocalSqlServer"

    Please see this Knowledge Base article on how to setup ASP.NET Membership. I wrote a test script to connect to your database, and it works fine.
     
    Last edited by a moderator: Oct 14, 2015
    ComputerMan and Michael like this.
  7. Elshadriel,

    yeah, you are my hero!!!!!

    Thank you so much..

    Jurgen
     
    Last edited by a moderator: Oct 14, 2015
    ComputerMan and Elshadriel like this.
  8. @Elshadriel, the article you posted above (in 2014) on how to setup ASP.NET Membership is no longer available at the link. Can you please re-post the correct link. Thank you so much!
     
  9. Elshadriel

    Elshadriel Winhost Staff

    Sorry, the Knowledge Base article has been deprecated but a copy of the same instructions can be found here.
     
    Michael and SonnyK like this.
  10. @Elshadriel ......Thank you so much!
     
    Elshadriel likes this.

Share This Page