Page 1 of 1

Unable to connect to any mySQL host

Posted: Wed Jan 10, 2018 2:08 am
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?

Re: Unable to connect to any mySQL host

Posted: Thu Jan 11, 2018 1:38 am
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

Re: Unable to connect to any mySQL host

Posted: Thu Jan 11, 2018 6:34 am
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();

Re: Unable to connect to any mySQL host

Posted: Fri Jan 12, 2018 4:50 am
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