When the crystal report is printed, an error message is displayed, indicating a communication error. Print will stop

Source: Internet
Author: User
I used the PULL mode method uploaded on the Internet to load the report. When printing, an error occurs: a communication error occurs. Print will stop
The data source I use is the stored procedure of SQL Server.

Solution:
Bind the crystal report to page_init.

Private void page_init (Object sender, eventargs E)
{
Cr_bind ();
}
Private void buttonimg_click (Object sender, system. Web. UI. imageclickeventargs E)
{
Cr_bind ();
}


Public void cr_bind ()
{
// Crystalreport. rpt is the name of the crystal report file. crystalreportsource1 is the object of the crystal report data source added to the page from the toolbox.

Crystalreportsource1.reportdocument. Load (server. mappath ("crystalreport1.rpt "));
// This method must be used in setdatabaselogon PULL mode to set logon information. Parameters 1: User Name; parameter 2: password; parameter 3: Server; parameter 4: Database Name
Crystalreportsource1.reportdocument. setdatabaselogon ("sa", "sa", @ ".", "iccard ");
// Transmit parameters to the crystal report. Parameter 1: Parameter Name, parameter 2: parameter value;
Crystalreportsource1.reportdocument. setparametervalue ("areaname_text", "this is a test report ");
// Crystalreportsource1.reportdocument. setparametervalue ("shopname_text", "1 ");

// Bind the crystal report data source.
Crystalreportsource1.databind ();
// Crystalreportviewer1 is the crystal report browser.
Crystalreportviewer1.reportsource = crystalreportsource1;
Crystalreportviewer1.databind ();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.