2011-12-08 7 views
0

ストアドプロシージャを使用してクリスタルレポートを動的に生成したいと考えています。私はRASインプロセスsdkを使用します。私は既にデータセットでレポートを作成しました。私は後でレポートのフィールドのデータソースとして使用するために、ストアドプロシージャの出力にアクセスする方法がわからないストアドプロシージャに基づいてクリスタルレポートを作成する

ISCRProcedure proc1 = new Procedure(); 
     CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo newConnectionInfo = new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo(); 
     ISCRPropertyBag logonAttributes = new PropertyBag(); 
     PropertyBag connectionAttributes = new PropertyBag(); 
     logonAttributes.Add("Data Source", datasource); 
     logonAttributes.Add("Initial Catalog", "Northwind"); 
     logonAttributes.Add("Provider", "SQLOLEDB"); 
     connectionAttributes.Add("Database DLL", "crdb_ado.dll"); 
     connectionAttributes.Add("QE_DatabaseType", "OLE DB (ADO)"); 
     connectionAttributes.Add("QE_LogonProperties", logonAttributes); 
     connectionAttributes.Add("QE_SQLDB", true); 
     connectionAttributes.Add("Server Name", servername); 
     connectionAttributes.Add("SSO Enabled", false); 
     newConnectionInfo.Attributes = connectionAttributes; 
     newConnectionInfo.UserName = username; 
     newConnectionInfo.Password = password; 
     newConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE; 
     proc1.ConnectionInfo = newConnectionInfo; 
     proc1.Name = "sp_SelectAllOrders"; 
     oReportClientDocument.DatabaseController.AddTable(proc1); 

:私が使用している コードは以下の通りです。何か案が?

答えて

0

あなたが作業の例を参照したい場合、私は自由なC#クラスオブジェクトの作成者、データ層の作成者とにあるストアドプロシージャジェネレータを持っています。 http://radstudio.codeplex.com

RAD Studioには、100%のストアドプロシージャ、データ駆動型階層を作成します;

以下のコードはMSアプリケーションブロックからのものですが、上記のコードジェネレータのダウンロードではこのクラスのラッパーを使用して簡単にできます。

private static void FillDataset(SqlConnection connection, SqlTransaction transaction, CommandType commandType, 
     string commandText, DataSet dataSet, string[] tableNames, 
     params SqlParameter[] commandParameters) 
    { 
     if (connection == null) throw new ArgumentNullException("connection"); 
     if (dataSet == null) throw new ArgumentNullException("dataSet"); 

     // Create a command and prepare it for execution 
     SqlCommand command = new SqlCommand(); 
     bool mustCloseConnection = false; 
     PrepareCommand(command, connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection); 

     // Create the DataAdapter & DataSet 
     using (SqlDataAdapter dataAdapter = new SqlDataAdapter(command)) 
     { 

      // Add the table mappings specified by the user 
      if (tableNames != null && tableNames.Length > 0) 
      { 
       string tableName = "Table"; 
       for (int index = 0; index < tableNames.Length; index++) 
       { 
        if (tableNames[index] == null || tableNames[index].Length == 0) throw new ArgumentException("The tableNames parameter must contain a list of tables, a value was provided as null or empty string.", "tableNames"); 
        dataAdapter.TableMappings.Add(tableName, tableNames[index]); 
        tableName += (index + 1).ToString(); 
       } 
      } 

      // Fill the DataSet using default values for DataTable names, etc 
      dataAdapter.Fill(dataSet); 

      // Detach the SqlParameters from the command object, so they can be used again 
      command.Parameters.Clear(); 
     } 

     if (mustCloseConnection) 
      connection.Close(); 
    } 
+0

RAS SDKのサンプルはありませんか?私はストアドプロシージャでデータセットを埋めることを避けたい。 – Rahma

関連する問題