여기에 있습니다. 필자는 잘 작동하는 데이터 집합 모델을 가지고 있으며 데이터베이스에서 데이터를 가져 와서 크리스탈 보고서에 제공합니다. 이 솔루션은 작동하지만 매우 시간이 당신이 내부 statementID으로 그룹을 모든 문에 대한 데이터를 검색하는 경우가 빠를 것입니다 ...이 일을 어떤 다른 방법이 있는지 궁금 해서요더 좋은 방법이 있나요?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Oracle.DataAccess.Client;
using System.Data;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string connetionString = null;
OracleConnection connection;
OracleDataAdapter OracleAdapter;
DataSet ds = new DataSet();
string firstSql = null;
connetionString = "datasoruce";
connection = new OracleConnection(connetionString);
string secondSql = "select statementnumber from erocks.statement_data_domestic";
connection.Open();
//OracleAdapter = new OracleDataAdapter(firstSql, connection);
//OracleAdapter.Fill(ds, "domestic");
OracleAdapter = new OracleDataAdapter(secondSql, connection);
OracleAdapter.Fill(ds, "statement");
connection.Close();
ReportDocument reportDoc = new ReportDocument();
reportDoc.Load(@"c:\users\desktop\statement.rpt");
DataTable stmt = ds.Tables["statement"];
string stmtnumber="";
for (int i = 0; i < stmt.Rows.Count - 1; i++)
{
stmtnumber = stmt.Rows[i][0].ToString();
firstSql = @"SELECT DISTINCT statement_header.statementnumber,
statement_details.invoicedate,
statement_details.invoicenumber,
statement_details.invoicetotal,
statement_details.doc_type,
statement_header.statementtotal,
statement_details.bunumber_ru,
statement_details.bunumber,
statement_details.description,
statement_details.reference_number,
statement_header.remto_zip,
statement_header.remto_city,
statement_header.remto_state,
statement_header.remto_mailname,
statement_header.remto_addr1,
statement_header.remto_addr2,
statement_header.remto_addr3,
statement_header.soldto_city,
statement_header.soldto_state,
statement_header.soldto_zip,
statement_header.soldto_addr1,
statement_header.soldto_addr2,
statement_header.soldto_addr3,
statement_header.balance_forward,
statement_header.statementdate,
statement_header.custid,
statement_header.custname,
statement_header.phone_prefix,
statement_header.phone_number,
statement_details.purchases,
statement_details.payments,
statement_details.misc_credit2,
statement_details.misc_credit1,
statement_header.company_number,
statement_header.statementpurchases,
statement_header.statementpayments,
statement_header.statementmisc_credit1,
statement_header.statementmisc_credit2,
statement_header.nomailnoprint,
statement_header.SOLDTOCOUNTRYCODE,
statement_header.SOLDTOCOUNTRYNAME,
statement_header.CREDITZEROFLAG
FROM STATEMENT_DATA_DOMESTIC statement_header
INNER JOIN STATEMENT_DATA_DETAILS statement_details
ON statement_header.statementnumber =
statement_details.statementnumber
where statement_header.statementnumber="+stmtnumber;
connection.Open();
OracleAdapter = new OracleDataAdapter(firstSql, connection);
OracleAdapter.Fill(ds, "domestic");
OracleAdapter.Dispose();
connection.Close();
reportDoc.SetDataSource(ds.Tables["domestic"]);
ExportOptions CrExportOptions;
DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
CrDiskFileDestinationOptions.DiskFileName = @"d:\pdf\"+ stmtnumber + ".pdf";
CrExportOptions = reportDoc.ExportOptions;
{
CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
CrExportOptions.FormatOptions = CrFormatTypeOptions;
}
reportDoc.Export();
ds.Tables["domestic"].Clear();
}
}
}
}
시간이 오래 걸리나요? 코드를 밟았 니? 많은 데이터가 있습니까? 문제가 정확히 무엇입니까? – LittleBobbyTables
많은 양의 데이터를 처리하는 데 너무 오래 걸리므로 레코드별로 레코드를 만들고 데이터베이스에 대한 연결도 개폐합니다. 나는 데이터 테이블의 모든 데이터를 가져올 수있는 방법을 생각하고 있었고 정확도를 복제하는 방법은 정확히 – user2315840
입니다. ds.Tables [ "domestic"]을 databse의 모든 데이터로 채우고 ds.tables [ statement "]에 모든 명령문 번호가 표시됩니다. 데이터베이스에 가까이 연결하십시오. ds.tables [ "statement"]의 모든 레코드를 구문 분석하여 해당 진술 번호에 대해서만 국내의 모든 관련 데이터를 가져 와서 crystalreport에 공급할 데이터 테이블에 배치하십시오. – user2315840