Symptom
当ノートでは、Crystal Reports .NET インプロセス Report Application Server (RAS) SDK を使用して、データベーステーブルを追加する方法について説明します。
Environment
- Microsoft Visual Studio 2005
- C#
- SAP Crystal Reports XI R2 Service Pack 2 以上のバージョン
Resolution
<サンプルコード>
using CrystalDecisions.ReportAppServer.ClientDoc;
using CrystalDecisions.ReportAppServer.Controllers;
using CrystalDecisions.ReportAppServer.DataDefModel;
using CrystalDecisions.CrystalReports.Engine;
// CR 変数
ReportDocument m_boReportDocument;
ISCDReportClientDocument m_boReportClientDocument; // レポートクライアントドキュメント
PropertyBag m_boLogonInfo; // ログオン情報
PropertyBag m_boAttributes; // ログオン属性
ConnectionInfo m_boConnectionInfo; // 接続情報
CrystalDecisions.ReportAppServer.DataDefModel.Table m_boTable; // テーブル
//*****************************
// レポートを初めから作成する
//*****************************
// 新規 ReportDocument を作成する
m_boReportDocument = new ReportDocument();
// RPT ファイルをロードする
m_boReportDocument.Load("..\\..\\dummy.rpt");
// ReportDocument の ReportClientDocument にアクセスする (EROM ブリッジ)
m_boReportClientDocument = m_boReportDocument.ReportClientDocument;
// レポートクライアントドキュメントを作成する
m_boReportClientDocument = new ReportClientDocument();
// 新規レポートドキュメント
m_boReportClientDocument.New();
// ログオンプロパティを作成する
m_boLogonInfo = new PropertyBag();
/* ODBC
// ログオン属性を作成する
m_boAttributes = new PropertyBag();
m_boAttributes["Database DLL"] = "crdb_odbc.dll";
m_boAttributes["QE_DatabaseType"] = "ODBC (RDO)";
m_boAttributes["QE_ServerDescription"] = "ODBC - Xtreme Sample Database 11.5";
m_boAttributes["QE_SQLDB"] = true;
m_boAttributes["Server Name"] = "Xtreme Sample Database 11.5";
*/
// DAO
// ログオン属性を作成する
m_boAttributes = new PropertyBag();
m_boAttributes["Database DLL"] = "crdb_dao.dll";
m_boAttributes["QE_DatabaseType"] = "Access";
// m_boAttributes["QE_ServerDescription"] = "ODBC - Xtreme Sample Database 11.5";
//m_boAttributes["QE_SQLDB"] = true;
m_boAttributes["Server Name"] = "C:\\Program Files\\Business Objects\\Common\\3.5\\Samples\\En\\Databases\\xtreme.mdb";
// 接続情報を作成する
m_boConnectionInfo = new ConnectionInfo();
m_boConnectionInfo.Attributes = m_boAttributes;
m_boConnectionInfo.UserName = "Admin";
m_boConnectionInfo.Password = "";
m_boConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindSQL;
// テーブルを作成する
m_boTable = new CrystalDecisions.ReportAppServer.DataDefModel.Table();
m_boTable.ConnectionInfo = m_boConnectionInfo;
m_boTable.Name = "Customer";
m_boTable.Alias = "Customer";
// テーブルを追加する
m_boReportClientDocument.DatabaseController.AddTable(m_boTable, null);
Crystal Reports XI R2 Service Pack 2 以上では、Crystal Reports .NET SDK を介してインプロセス RAS エンジンを使用することにより、追加ライセンスを購入しなくても、レポートモディフィケーション API にアクセスすることができます。
See Also
Keywords
RAS, Modification, In-Process, .NET, Create, Add, Remove, Change, Modify, ReportClientDocument, inproc, database, モディフィケーション, インプロセス, 作成, 追加, 削除, 変更, 修正, データベース , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To