2011-12-08 1 views
0

저장 프로 시저를 사용하여 Crystal 보고서를 동적으로 생성하려고합니다. 나는 RAS in-process SDK를 사용합니다. 이미 데이터 세트로 보고서를 만들었습니다. 나중에 보고서의 필드에 대한 데이터 소스로 사용하기 위해 저장 프로 시저의 출력에 액세스하는 방법을 모르는저장 프로 시저를 기반으로 Crystal 보고서 만들기

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); 

: 내가 사용하고 코드는 다음과 같다. 어떤 생각? http://radstudio.codeplex.com

RAD 스튜디오 100 % 저장 프로 시저 구동 데이터 계층을 만듭니다 : 당신은 작업 예제를보고 싶은 경우

답변

0

, 나는 무료로 C# 클래스 개체 작성자, 데이터 계층 작성자와에있는 저장 프로 시저의 생성을 ;

아래 코드는 MS Application Block에서 가져온 코드이지만 위 코드 생성기에서이 클래스에 대한 래퍼를 사용하면 쉽게 사용할 수 있습니다.

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

관련 문제