locked
Web Application runs fine in Visual Studio but when Published no longer connects to MySQL RRS feed

  • Question

  • User1273569149 posted

    I get the following error after publishing my web application to my hosting account.

    Authentication to host 'localhost' for user 'BanditsBaseball' using method 'mysql_native_password' failed with message: Reading from the stream has failed.

    If I run this on my development machine it connects to the database just fine. Only when I publish do I get this problem.

    When I am running in development I connect to calantha.arvixe.com
    When I publish I change the Server field for the connection string to localhost like I am supposed to.

    Any help in this would be greatly appreciated.


    I am basically following this example which is all my code. Again running on my development machine it works fine (connecting remotely) as soon as I publish (connected locally) I get this problem.

    http://www.aspsnippets.com/Articles/Use-and-connect-to-MySQL-Database-in-ASPNet-Application-using-MySQLConnector.aspx

    Wednesday, April 6, 2016 7:35 PM

Answers

  • User-359936451 posted

    The Error says that this is a stream error. I don't believe your connection string should be using a stream.

    Post your connection strings for the Dev PC and the Production server, (BE SURE TO REMOVE PASSWORDS).

    You may also want to check with your server admin or ISP to be certain you have the correct SQL Server connection info. This really sounds like that is where your issues is at.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 6, 2016 7:54 PM

All replies

  • User-359936451 posted

    The Error says that this is a stream error. I don't believe your connection string should be using a stream.

    Post your connection strings for the Dev PC and the Production server, (BE SURE TO REMOVE PASSWORDS).

    You may also want to check with your server admin or ISP to be certain you have the correct SQL Server connection info. This really sounds like that is where your issues is at.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 6, 2016 7:54 PM
  • User1273569149 posted

    connectionString="server=cflbandits.com;port=3306;user=BanditsBaseball;password=******;database=bandits;Convert Zero Datetime=True"

    This is the only connection string I am using. Remember, When I run this in Visual Studio, it connects to the MySQL server that is also hosted through my hosting account Arvixe just fine. Only when published to Arvixe do I get this behavior

    The code is pretty simple:

    protected void Page_Load(object sender, EventArgs e)
            {
                string connStr = "server=cflbandits.com;user=BanditsBaseball;database=bandits;port=3306;password=******;";
                MySqlConnection conn = new MySqlConnection(connStr);
                try
                {
    
                    conn.Open();
    
                    Response.Write("SQL Opened.");
    
                }
                catch (Exception ex)
                {
                    Response.Write(ex.ToString());
                }
    
                conn.Close();
                Response.Write("Connection Closed.");
            }



    Wednesday, April 6, 2016 7:55 PM
  • User1273569149 posted

    Just got it fixed. Arvixe has the correct MySql.Data.dll to include with the fix and the proper web.config setting that needed to be added.

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" />
            <bindingRedirect oldVersion="0.0.0.0-6.7.4.0" newVersion="6.5.4.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>

    Wednesday, April 6, 2016 8:17 PM
  • User-359936451 posted

    Thanks for the credit for pointing you in the right direction!!

    Wednesday, April 6, 2016 8:27 PM
  • User1273569149 posted

    I got you March11!!

    Wednesday, April 6, 2016 8:28 PM
  • User-359936451 posted

    Good looking out!!!

    Wednesday, April 6, 2016 8:32 PM