0

以下のデータベース認証コードの有無にかかわらず試してみました。

認証ではログインに失敗します...通常はODBCを使用しますが、ODBC接続にリンクする方法がわかりません。

認証がないと、空のレポートが出力されます (レコードが返されなかったかのように、実際のレポート)。

また、印刷機能で from および to ページのパラメーターが必要なため、ページ数がわからない場合、レポート全体を印刷する方法を教えてください。

レポートは Crystal Reports XI v11.5 で作成されました

助けてくれてありがとう。

これが私がこれまでに持っているものです:

printReport()
{
        ReportDocument cryRpt = new ReportDocument();
        cryRpt.RefreshReport += reportLoaded;
        cryRpt.Load(myReport);

        TableLogOnInfo crTableLogonInfo = new TableLogOnInfo();
        ConnectionInfo crConnectionInfo = new ConnectionInfo();
        Tables crTables;

        crConnectionInfo.ServerName = "myServer";
        crConnectionInfo.DatabaseName = "myDatabase";
        crConnectionInfo.UserID = "myUser";
        crConnectionInfo.Password = "myPass";

        crTables = cryRpt.Database.Tables;

        foreach (Table table in crTables)
        {
            crTableLogonInfo = table.LogOnInfo;
            crTableLogonInfo.ConnectionInfo = crConnectionInfo;
            table.ApplyLogOnInfo(crTableLogonInfo);
        }

        cryRpt.SetParameterValue("@report_type", type);

        cryRpt.Refresh();
}

reportLoaded(object sender, EventArgs e)
{
    PrintDialog print = new PrintDialog();
    DialogResult dr = print.ShowDialog();

    if (dr == DialogResult.OK)
    {
        ReportDocument cryRpt = (ReportDocument)sender;
        cryRpt.PrintOptions.PrinterName = print.PrinterSettings.PrinterName;
        cryRpt.PrintToPrinter(print.PrinterSettings.Copies, print.PrinterSettings.Collate, print.PrinterSettings.FromPage, print.PrinterSettings.ToPage);
    }
}
4

1 に答える 1

1

ODBC への接続では、ConnectionInfo オブジェクトの ServerName プロパティを使用して接続文字列/dsn を指定できる必要があります。いくつかの例については、次の質問の回答を参照してください。

実行時に Crystal Report の ODBC データベース接続を変更するにはどうすればよいですか?

質問の 2 番目の部分では、PrintToPrinter メソッドの両方のページ番号パラメーターに 0 を使用して、すべてのページを印刷できるはずです。

お役に立てれば。

于 2011-06-03T20:30:08.830 に答える