感谢您使用微软产品。在使用Crystal Report制作报表时,碰到出现Database Login数据库登录窗口,是由于报表访问的后台数据库MS SQL Server需要提供登录信息。一般情况下,如果后台数据库需要认证(如MS SQL Server),则应提供登录信息。如下提供一段示例代码供您参考:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
……
        Dim crReport As New CrystalReport1()
        Dim repDB As Database = crReport.Database
        Dim repTbls As Tables = repDB.Tables
        Dim repTbl As Table        repTbl = repTbls(0)
        Dim logonInfo As TableLogOnInfo = repTbl.LogOnInfo
        logonInfo.ConnectionInfo.Password = "password"
        repTbl.ApplyLogOnInfo(logonInfo)
        CrystalReportViewer1.ReportSource = crReport
请根据您系统的实际情况,将提供的代码进行修改。希望以上答复给您带来帮助。
关于Crystal Report的更详细信息,请参考如下网站:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q100368
http://community.crystaldecisions.net/
 — 微软全球技术中心 VB支持中心本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。

解决方案 »

  1.   

    借贵地一用
    打印时报:Request canceled by user
    是怎么回师??
    楼上兄弟碰到过吗?ReportDocument report = new ReportDocument();
    report.Load("d:\\inetpub\\wwwroot\\test\\CrystalReport1.rpt");
    report.PrintOptions.PrinterName = "HP6L";
    report.PrintToPrinter(0, false,0,0);
      

  2.   

    详细为:
    Error in File d:\inetpub\wwwroot\test\CrystalReport1.rpt: Request cancelled by the user.
      

  3.   

    感谢您使用微软产品。根据您提供的代码,问题可能出现在PrintToPrinter()这个方法的参数上。该方法的原型如下:
    public virtual void PrintToPrinter (int nCopies , bool collated , int startPageN , int endPageN );
    其中参数说明:
    Parameters
    nCopies 打印份数;
    collated 是否逐份打印;
    startPageN 开始打印页;
    endPageN 最后打印页;
    如果打印所有页,则设置startPageN = 0和endPageN = 0
    因此,应该将代码report.PrintToPrinter(0, false,0,0);修改为report.PrintToPrinter(1, false,0,0);,下面提供一段示例代码,供您参考:
    using CrystalDecisions.Shared;
    using CrystalDecisions.CrystalReports.Engine;
    ……
    private void btnPrint_Click(object sender, System.EventArgs e)
    {
    PageMargins margins; // Get the PageMargins structure and set the 
    // margins for the report.
    ReportDocument Report = new ReportDocument();
    Report.Load ("C:\\homeworks\\Report\\Chart.rpt"); margins = Report.PrintOptions.PageMargins;
    margins.bottomMargin = 350;
    margins.leftMargin = 350;
    margins.rightMargin = 350;
    margins.topMargin = 350;
    // Apply the page margins.
    Report.PrintOptions.ApplyPageMargins(margins); // Select the printer.
    string printerName = "实际打印机名称";
    Report.PrintOptions.PrinterName = printerName; // Print the report. Set the startPageN and endPageN
    // parameters to 0 to print all pages.
    Report.PrintToPrinter(1, false,0,0);
    }请根据您系统的实际情况,将提供的代码进行修改。希望以上答复给您带来帮助。关于PrintToPrinter方法的更详细信息,请参考如下网站:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/crystlrf/html/crlrfreportdocumentclassprinttoprintermethodtopic.asp关于Crystal Report的更详细信息,请参考如下网站:
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;q100368
    http://community.crystaldecisions.net/
     — 微软全球技术中心 VB支持中心本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
    为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
      

  4.   

    非常感谢acptvb
    我要是修炼到你的境界,.net早该被另一种大牛的东西取代了呵呵