Unable to connect to any mySQL host

Stimulsoft Reports.NET discussion
Post Reply
Eric
Posts: 6
Joined: Sun Sep 03, 2017 1:57 pm

Unable to connect to any mySQL host

Post by Eric »

I have deploy my app include Stimulsoft.Base.dll, Stimulsoft.Controls.dll, Stimulsoft.Controls.Win.dll, Stimulsoft.Report.dll, Stimulst oft.Report.Win.dll

But when i tried to run my app containing stimulsoft report, its written "Unable to connect to any mySQL host".

Code: Select all

using (StiReport report = new StiReport())
                    {
                        report.Dictionary.Databases.Clear();

                        if (cboTransactionType.Text.Equals("CASH"))
                        {
                            report.Load("CashInvoice.mrt");
                            report.Dictionary.Databases.Add(new StiMySqlDatabase("cashinvoice",
                                CommonDaoBase.ActualConnectionString));
                        }
                        else
                        {
                            report.Load("TermInvoice.mrt");
                            report.Dictionary.Databases.Add(new StiMySqlDatabase("terminvoice",
                            CommonDaoBase.ActualConnectionString));
                        }
                        
                        report.Dictionary.Databases.Add(new StiMySqlDatabase("company",
                            CommonDaoBase.ActualConnectionString));
                        
                        report.Dictionary.Variables["varCompanyCode"].ValueObject = Form1.CompanyCode.ToString();
                        report.Dictionary.Variables["varInvNumber"].ValueObject = intInvNumber.ToString();
                        //report.Show(true);
                        report.Print(true);
                        //report.Print(false);
                    }
What could be the problem?
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Re: Unable to connect to any mySQL host

Post by Edward »

Hi Eric,

Please try to remove the 'using' statement from the code.

And also it looks by the exception message that there is probably some issues connecting to the MySql database for some reason.
Could you please try to add a simple query with that connection string in a stand-alone Stimulsoft Reports.Net Designer and to try executing the basic report from there?

Thank you,
Edward
Eric
Posts: 6
Joined: Sun Sep 03, 2017 1:57 pm

Re: Unable to connect to any mySQL host

Post by Eric »

Thanks for the reply, Edward.

I change the code to be :

Code: Select all

report.Load("CashInvoice.mrt");
report.Dictionary.Databases.Clear();
report.Dictionary.Databases.Add(new StiMySqlDatabase("MySQL", CommonDaoBase.ActualConnectionString));
First, load the report, then clear the Dictionary, after that add new Dictionary with new connectionString.
and instead using variables, i use parameters.

Code: Select all

report.DataSources[0].Parameters[0].Value = Form1.CompanyCode.ToString();
report.DataSources[1].Parameters[0].Value = intInvNumber.ToString();
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Re: Unable to connect to any mySQL host

Post by Edward »

Hi Eric,

No problem, good spot, the load of the report should be definitely a starting point before clearing of the Dictionary.

Thank you,
Edward
Post Reply