cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal report for VS 2010 application is a little bit slow when run in a 64 bit machine

Former Member
0 Kudos

Hi,

Our application takes for about 30 seconds to more than 1 minute to load only a simple report (sales receipt) in a 64 bit machine preferably windows 7 and windows 2008 which is too slow for us as a 64 bit user. But this report is very fast in a 32 bit pc (windows xp and windows 7) that it takes only (a blink of an eye, ) 0.5s to 2 seconds to load, in which i'm a lucky enough because most users of our company is still using windows xp which I think crystal report application is very comfortable with. How is that happened? I don't know how this delay has happened in our 64 bit pc and I still don't how to fix this.

Anyway, the application is in c# with crystal report for vs2010 sp8 x64 for 64 bit pc and sales receipt loads only data from textboxes and datagridview that uses a dataset to push the data to the crystal report viewer (without sql server intervention).

I need help for this problem. Your help will be greatly appreciated.

Thank you very much.

Hardz

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Hello Hardie

My first inclination would be to check out the database client - assuming you are using "SAP Crystal Reports, Version for Visual Studio .NET', SP 8(?). SP 8 can be downloaded from here:

So, assuming you are on SP 8, how are you connecting to the database (OLE DB, ODBC, etc.)?

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow us on Twitter

0 Kudos

And check off any of the Verify options in Report Options so it doesn't try to connect to your DB.

Don

Former Member
0 Kudos

Hi Ludek,

Yes, I am using the latest CR v.13.0.8.1216 for vs .net 2010 after upgrading from sp7, and I am also using OLE DB to connect to the database. Wherein there's an Install Executable installed on windows server 2008 x64 and MSI 64 bit for win 7 x64 users. And as I said before it is a little bit slow on 64 bit pc especially on our windows server 2008 r2.

Actually, before, I am using a win7 64 bit for this c# application that i'm developing but due to this problem on crystal report I had to switched back to 32 bit which i'm currently using. That's why loading any kind of report (with or without thousands of data to load or with or without sql) to my pc is very very fast.

So since I am using Ole db to connect to sql server, most of our reports are directly connected to the database especially our sales listing report, inventory reports, etc, in which data is loaded to crystal report viewer. Except for sales receipt (invoices receipt, quotation, etc.) because textboxes and datagridview pulls/saves its data from/to the database. So after save/load, the sales form now is ready for printing. Anyway, for better reference I can provide you with my code here on how I can push the data from dgv to crystal report.

At quotation form:

//Uses delegate to create and replace a default print button

public delegate void PrintDelegate();

        QuotationReceipt _qouReceipt;

        private void btnPrintPreview_Click(object sender, EventArgs e)

        {

            this.Cursor = Cursors.WaitCursor;

            _qouReceipt = new QuotationReceipt(this);

            PrintDelegate mymethod = new PrintDelegate(CustomPrint);

            loadDataToOtherForm();

            _qouReceipt.CustomPrint= mymethod;

            _qouReceipt.loadReceipt();

            _qouReceipt.ShowDialog();

            this.Cursor = Cursors.Default;

        }

        private void CustomPrint()

        {

            _qouReceipt.printme();

        }

        private void loadDataToOtherForm()

        {

            //_qouReceipt.count = dgvDesc.Rows.Count;

            _qouReceipt.custName = txtNameTo.Text;

            _qouReceipt.custAddress = txtAdd.Text;

            _qouReceipt.date = dtpDate.Text;

            _qouReceipt.tax = double.Parse(lblTotalTax.Text);

            _qouReceipt.netTotal = double.Parse(lblNetTotal.Text.ToString());

            _qouReceipt.totalSales = double.Parse(lblNetTotal.Text.ToString()) - double.Parse(lblTotalTax.Text);

            _qouReceipt.quotationNo = txtcsno.Text;

            _qouReceipt.custPhone = txtPhone.Text;

            _qouReceipt.attention = txtAttention.Text;

            _qouReceipt.validUntil = "";

            _qouReceipt.preparedBy = valAgentName;

        }

Then at quotation receipt form:

dsCsReceipt dsCs; //name of created dataset that must contain a dgv value

        ParameterValues paramValue;

        ParameterDiscreteValue discreteValue;

        ParameterFieldDefinition fieldDefinition;

        private System.Drawing.Printing.PrintDocument printDocument1;

        private System.Windows.Forms.PrintDialog printDialog1;

        csQuotation csQuote; //crystal report name

        public delegate void CustomPrintDelegate();

        public Delegate CustomPrint { get; set; }

private void QuotationReceipt_Load(object sender, EventArgs e)

        {

            this.WindowState = FormWindowState.Maximized;

            foreach (Control control in crvQuotation.Controls)

            {

                if (control is System.Windows.Forms.ToolStrip)

                {

                    //Default Print Button

                    ToolStripItem tsItem = ((ToolStrip)control).Items[1];

                    tsItem.Click += new EventHandler(tsItem_Click);

                    //Custom Button

                    ToolStripItem tsNewItem = ((ToolStrip)control).Items.Add("");

                    tsNewItem.ToolTipText = "Print Report";

                    tsNewItem.Image = Properties.Resources.printer_icon3;

                    tsNewItem.Tag = "99";

                    ((ToolStrip)control).Items.Insert(0, tsNewItem);

                    tsNewItem.Click += new EventHandler(tsNewItem_Click);

                }

            }

        }

void tsNewItem_Click(object sender, EventArgs e)

        {

            if (CustomPrint != null)

            {

                CustomPrint.DynamicInvoke(null);

            }

        }

        void tsItem_Click(object sender, EventArgs e)

        {

            if (CustomPrint != null)

            {

                CustomPrint.DynamicInvoke(null);

            }

        }

public void loadReceipt()

        {

            string invcode;

            DataTable u;

            DataRow s;

            dsCs = new dsCsReceipt();

            u = dsCs.Tables.Add("DtCsReceipt");

            u.Columns.Add("Qty", Type.GetType("System.String"));

            u.Columns.Add("UOM", Type.GetType("System.String"));

            u.Columns.Add("Description", Type.GetType("System.String"));

            u.Columns.Add("UnitPrice", Type.GetType("System.String"));

            u.Columns.Add("Amount", Type.GetType("System.String"));

            u.Columns.Add("Discount", Type.GetType("System.String"));

            try

            {

                for (int i = 0; i < _quo.dgvDesc.Rows.Count; i++)

                {

                    s = u.NewRow();

                    s["Qty"] = _quo.dgvDesc.Rows[i].Cells["Qty"].Value.ToString();

                    s["UOM"] = _quo.dgvDesc.Rows[i].Cells["Uom2"].Value.ToString();

                    invcode = _quo.dgvDesc.Rows[i].Cells["InvCode"].Value.ToString();

                    if (invcode == "FAB" || invcode == "UI")

                    {

                        invcode = "";

                    }

                    else

                    {

                        invcode = invcode + " ";

                    }

                    s["Description"] = invcode +                                             _quo.dgvDesc.Rows[i].Cells["Description"].Value.ToString();

                    s["UnitPrice"] = _quo.dgvDesc.Rows[i].Cells["UnitPrice"].Value.ToString();

                    s["Amount"] = _quo.dgvDesc.Rows[i].Cells["Amount2"].Value.ToString();

                    s["Discount"] = _quo.dgvDesc.Rows[i].Cells["Discount2"].Value.ToString();

                    u.Rows.Add(s);

                }

            }

            catch (Exception) { }

            csQuote = new csQuotation();

            csQuote.SetDataSource(dsCs.Tables[1]);

            loadParameter();

            crvQuotation.ReportSource = csQuote;

            crvQuotation.Refresh();

        }

private void loadParameter()

        {

            ParameterFieldDefinitions paramFieldDefinitions;

            paramValue = new ParameterValues();

            discreteValue = new ParameterDiscreteValue();         

            paramFieldDefinitions =  csQuote.DataDefinition.ParameterFields;

            discreteValue.Value = address;

            fieldDefinition = paramFieldDefinitions["Address"];

            commonParam();

            discreteValue.Value = phone;

            fieldDefinition = paramFieldDefinitions["Phone"];

            commonParam();

            discreteValue.Value = date;

            fieldDefinition = paramFieldDefinitions["Date"];

            commonParam();

            discreteValue.Value = quotationNo;

            fieldDefinition = paramFieldDefinitions["QuotationNo"];

            commonParam();

            discreteValue.Value = custName;

            fieldDefinition = paramFieldDefinitions["Customer"];

            commonParam();

            ......................other parameters

}

void commonParam()

        {

            paramValue.Clear();

            paramValue.Add(discreteValue);

            fieldDefinition.ApplyCurrentValues(paramValue);

        }

public void printme()

        {

            this.Cursor = Cursors.WaitCursor;

using (printDocument1 = new System.Drawing.Printing.PrintDocument())

            {

                using (this.printDialog1 = new PrintDialog())

                {

                    this.printDialog1.Document = this.printDocument1;

                    DialogResult dr = this.printDialog1.ShowDialog();

                    if (dr == DialogResult.OK)

                    {

                        int nCopy = this.printDocument1.PrinterSettings.Copies;

                        int sPage = this.printDocument1.PrinterSettings.FromPage;

                        int ePage = this.printDocument1.PrinterSettings.ToPage;

                        string PrinterName = this.printDocument1.PrinterSettings.PrinterName;

                        try

                        {

                            csQuote.PrintOptions.PrinterName = PrinterName;

                            csQuote.PrintToPrinter(nCopy, false, sPage, ePage);

                            _quo.printcount++;

                        }

                        catch (Exception err)

                        {

                            MessageBox.Show(err.ToString());

                        }

                    }

                }

            }

            this.Cursor = Cursors.Default;

        }

Our quotation receipt can accept only from 1 to 20 rows. I don't know if there's a problem with this code or the designer itself in a 64 bit environment maybe I can re-modify this through your help .

Thank you very much.

Hardz

Former Member
0 Kudos

Hi Don,

Actually, I am using the default report options that is checked during the creation of report and here is the report options that were checked at Quotation receipt report:

     -Database server is case-insensitive

     -Use indexes or server for speed

     -verify on first refresh

     -select distinct data for browsing and

     -prompt for hyperlinks

Then other than that were unchecked.

I tried to unchecked the third one, but still no luck after I loaded the application to the windows server 2008 r2 64 bit. I think there's something process/es that is holding the report to make a delay in a 64 bit pc which I don't know where it resides, but through your help guys maybe I can overcome this problem.

Anyway, I have posted some codes a follow up to Mr. Ludek's reply, and maybe you could try to study it if there's a problem with that code.

Thank you very much.

Hardz

former_member183750
Active Contributor
0 Kudos

Hello Hardie

As I read the code, the report is actually not even aware that there is a database in play as you are passing it a dataset:

    csQuote = new csQuotation();

    csQuote.SetDataSource(dsCs.Tables[1]);

    loadParameter();

    crvQuotation.ReportSource = csQuote;

    crvQuotation.Refresh();

Now, I wonder if we actually need to use crvQuotation.Refresh(); ?. E.g.; this would be the 1st line to remove.

Next, I see you populating the dataset with data. E.g.;

_qouReceipt.custAddress = txtAdd.Text;

Yet a bit lower in the code, you are using CR parameters for the address, etc.;

discreteValue.Value = address;

            fieldDefinition = paramFieldDefinitions["Address"];

            commonParam();

Not sure why the report has parameters for the address?

If I were testing this, I'd simplify it quite a bit. As it is, it is really hard to determine where the slow down is occurring. So, I'd do the following:

Create an XML file from your current app:

csQuote.WriteXml(xmlPath, XmlWriteMode.WriteSchema)

Create a new test app:

No print button, no viewer.

A report with no parameters

Code for app:

Load report

Create a dataset off of the above XML

Pass the dataset to the report

Print using PrintToPrinter.

Test the app as 32 bit and 64 bit compile (or Any CPU). Compare the results.

- Ludek

Former Member
0 Kudos

Hi Ludek,

Sorry for a very late reply, it has been a long while since I created this thread. Anyway, using the latest sp 9 version of crystal report solved this problem on my 64 bit pc. All of my reports is very fast now, even if I load hundreds of thousands of data from a database to crystal, since I implemented this new version. I think there's a little known problem with the previous version of crystal report that is very hard to address where slowness occurred. But thanks to this new version all my reports problem were finally solved.

Thank you very much for your reply and effort.

best regards,

Hardz

Answers (0)