MySql db connection problem
Posted: Wed Feb 01, 2017 3:48 pm
Hello,
In one of my reports, I am getting this exception:
MySql.Data.MySqlClient.MySqlException (0x80004005): Authentication to host '<myserver>' for user '<myuser>' using method 'mysql_native_password' failed with message: Reading from the stream has failed. ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Reading from the stream has failed. ---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
Background:
We are using Visual Studio 2015.
When I run the reports individually, this works fine.
When I run the reports, e.g. in a big for loop, deployed in a Azure Worker Role (similar to a windows service), I get the above error.
In our .Net code, we wrap our code in the 'using' statement, like this
using (StiReport report = new StiReport())
{
// pseudo code:
report.Load(reportPath);
report.Compile();
(report.CompiledReport.Dictionary.Databases["MasterData"] as StiMySqlDatabase).ConnectionString = _connectionStringMasterDb;
report.Render(false);
// then, we export the report to PDF
}
We then have mapped our sql command like this:
<SqlCommand>CALL `my_stored_proc`(@param1, @param2);</SqlCommand>
My main question - how do I solve this problem? Namely, what is the best practice to manage the database connections?
Thank you.
In one of my reports, I am getting this exception:
MySql.Data.MySqlClient.MySqlException (0x80004005): Authentication to host '<myserver>' for user '<myuser>' using method 'mysql_native_password' failed with message: Reading from the stream has failed. ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Reading from the stream has failed. ---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
Background:
We are using Visual Studio 2015.
When I run the reports individually, this works fine.
When I run the reports, e.g. in a big for loop, deployed in a Azure Worker Role (similar to a windows service), I get the above error.
In our .Net code, we wrap our code in the 'using' statement, like this
using (StiReport report = new StiReport())
{
// pseudo code:
report.Load(reportPath);
report.Compile();
(report.CompiledReport.Dictionary.Databases["MasterData"] as StiMySqlDatabase).ConnectionString = _connectionStringMasterDb;
report.Render(false);
// then, we export the report to PDF
}
We then have mapped our sql command like this:
<SqlCommand>CALL `my_stored_proc`(@param1, @param2);</SqlCommand>
My main question - how do I solve this problem? Namely, what is the best practice to manage the database connections?
Thank you.