c# - create a temp datatable to store values of records -


need dataset working on have dataset 2 tables 1 holds primary key values "statementnumber" , other hold rest of details 1 many relationship

now want parse through each statementnumber 1 table details second table , place record new data table. 1 record @ time using loop till reach end of records primary table. how can c#?

so far have both tables in same dataset.

here code have already.

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);             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        statement_data_domestic statement_header             inner join statement_data_dom_details statement_details                on statement_header.statementnumber =                      statement_details.statementnumber";             string secondsql = "select statementnumber statement_data_domestic";                 connection.open();                 oracleadapter = new oracledataadapter(firstsql, connection);                 oracleadapter.fill(ds, "domestic");                 oracleadapter = new oracledataadapter(secondsql, connection);                 oracleadapter.fill(ds, "statement");              oracleadapter.dispose();                 connection.close();                  ds.relations.add("statementnumber", ds.tables["statement"].columns["statementnumber"], ds.tables["domestic"].columns["statementnumber"]);        //gridview1.datasource = ds.tables[1];            //   gridview1.databind();                 reportdocument reportdoc = new reportdocument();                 reportdoc.load(@"c:\users\soniara\desktop\statement.rpt");                 datatable d3 = ds.tables["statement"];                 foreach (datarow arpan in d3.rows)                 {                     datarow[] details = arpan.getchildrows("statementnumber");                       foreach (datarow detail in details)                     {                          reportdoc.setdatasource(detail);                         exportoptions crexportoptions;                         diskfiledestinationoptions crdiskfiledestinationoptions = new diskfiledestinationoptions();                         pdfrtfwordformatoptions crformattypeoptions = new pdfrtfwordformatoptions();                         crdiskfiledestinationoptions.diskfilename = @"d:\converte5_1_13"+detail+".pdf";                         crexportoptions = reportdoc.exportoptions;                         {                             crexportoptions.exportdestinationtype = exportdestinationtype.diskfile;                             crexportoptions.exportformattype = exportformattype.portabledocformat;                             crexportoptions.destinationoptions = crdiskfiledestinationoptions;                             crexportoptions.formatoptions = crformattypeoptions;                          }                         reportdoc.export();                      }                 }                 }     } } 

basically want retrieve 1 record @ time statement table , details details table , run through crystal report pdf output

my code works fine if give entire dataset source crytalreport.setdatasrouce

but makes 1 long pdf file , not small single statement files. trying do.

[replaced] if crystalreports supports dataview object datasource, can use this:

        foreach (datarow statementrow in ds.tables["statement"].rows)         {             var detail = new dataview(ds.tables["domestic"])             {                 rowfilter = string.format("statementnumber = {0}", statementrow["statementnumber"]),                 sort = "" // optional             };               reportdoc.setdatasource(detail);                             ....                       } 

otherwise can use this:

    foreach (datarow statementrow in ds.tables["statement"].rows)     {         var detail = getfilteredtable(ds.tables["domestic"], statementrow["statementnumber"]);          reportdoc.setdatasource(detail);                         ....     }       public datatable getfilteredtable(datatable dt, object statementnumber)     {         var detailrows = dt.select(string.format("statementnumber = {0}", statementnumber));         var filtereddt = dt.clone();         foreach (var detailrow in detailrows)         {             filtereddt.rows.add(detailrow.itemarray);         }         return filtereddt;     } 

another suggestion might want investigate grouping in crystal reports, might able achieve need creating parameter statement number , passing report itself, , have filter you. not know details know possible.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -