c# - crystal report Unable to connect: incorrect log on parameters -


hi friend i've created crystal report parameter,its running in while executing in source code not load in while config after iis shows error unable connect log on parameters. please check code , correct me.

hi frinds if comment ostream = (memorystream)reportdocument.exporttostream(exportformattype.portabledocformat); line , response.binarywrite(ostream.toarray()); report generate in iis not in proper pdf formate pls me want generate in pdf formate pls guide me

public partial class frm_mrprint : system.web.ui.page {     sqlconnection con = new sqlconnection(configurationmanager.appsettings["conn"].tostring());     protected void page_load(object sender, eventargs e)     {         if (!page.ispostback)         {             mr();         }     }     protected void button1_click(object sender, eventargs e)     {          memorystream ostream;         response.clear();         response.buffer = true;           reportdocument reportdocument = new reportdocument();          reportdocument.load(server.mappath("mr.rpt"));         reportdocument.setdatabaselogon("sa", "admin123", "vivek", "purchase");          reportdocument.setparametervalue("mrno", ddlmrno.selecteditem.text);          crystalreportviewer1.reportsource = reportdocument;          ostream = (memorystream)reportdocument.exporttostream(exportformattype.portabledocformat);         response.contenttype = "application/pdf";         try         {              //write report response stream              response.binarywrite(ostream.toarray());              response.end();          }          catch (exception ex)         {             label2.visible = true;             label2.text = "error:" + server.htmlencode(ex.message.tostring());           }                  {              //clear stream              ostream.flush();              ostream.close();              ostream.dispose();          }          //in case want export attachment use line below          //crreport.exporttohttpresponse(exportformattype.portabledocformat, response, true, "your exported file name");      }      public void mr()     {          ddlmrno.items.clear();         listitem frstitem = new listitem();         frstitem.text = "- select -";         ddlmrno.items.add(frstitem);         ddlmrno.selectedindex = 0;         con.open();         string sql = "";         sql = "select  distinct(mrno) dbo.tbl_kksmr status=1 order mrno asc";         sqlcommand cmd = new sqlcommand(sql, con);         sqldatareader rdr;         try         {             rdr = cmd.executereader();             while (rdr.read())             {                  listitem newitem = new listitem();                 newitem.text = rdr["mrno"].tostring().trim();                 newitem.value = rdr["mrno"].tostring().trim();                 ddlmrno.items.add(newitem);             }             rdr.close();         }         catch (exception ex)         {             response.write(ex.message);         }                 {             cmd.dispose();          } con.close();      } } 

this aspx file.....

 <cr:crystalreportviewer id="crystalreportviewer1" runat="server"                      autodatabind="true" oninit="crystalreportviewer1_init"  /> 

this cs file.....

      using system;         using system.collections.generic;         using system.linq;         using system.web;         using system.web.ui;         using system.web.ui.webcontrols;         using system.reflection;         using crystaldecisions.crystalreports.engine;         using crystaldecisions.shared;         using crystaldecisions.reporting;         using crystaldecisions;         using system.data.sqlclient;         using system.data;         using businessaccesslevel;         using businessaccesslevel.masters;          namespace texerp.reportcrystal.sales         {             public partial class cityreportcry : system.web.ui.page             {                 reportdocument doc;             }           protected void btnshowreport_click(object sender, eventargs e)                 {                     oldloadreport();                             }                private void oldloadreport()                 {                     doc = new reportdocument();                     doc.load(server.mappath("mr.rpt"));                doc.setdatabaselogon("sa", "admin123", "vivek", "purchase", false);                reportdocument.setparametervalue("@mrno", ddlmrno.selectedvalue);                 crystalreportviewer1.reportsource = doc;                 }                  protected void crystalreportviewer1_init(object sender, eventargs e)                 {                     oldloadreport();                 }             }         } 

code directly export .pdf

                exportoptions crexportoptions ;                 diskfiledestinationoptions crdiskfiledestinationoptions = new diskfiledestinationoptions();                 pdfrtfwordformatoptions crformattypeoptions = new pdfrtfwordformatoptions();                 crdiskfiledestinationoptions.diskfilename = "c:\\csharp.net-informations.pdf";                 crexportoptions = doc.exportoptions;                 {                     crexportoptions.exportdestinationtype = exportdestinationtype.diskfile;                     crexportoptions.exportformattype = exportformattype.portabledocformat;                     crexportoptions.destinationoptions = crdiskfiledestinationoptions;                     crexportoptions.formatoptions = crformattypeoptions;                 }                 doc.export(); 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -