sql server 2008 - c# crystal reports database logon error when deployed (works fine on dev-machine) -


i've created crystal report (version 2008) extract data sql 2008 server. has 10 subreports. works fine in crystal designer. wanted write small c# programm run report via crystal runtime, in deployed on different system.

here c# code

static void main(string[] args) {     runreport(convert.toint32(args[0]), args[1].tostring()); }  static void runreport(int stoerungid, string version) {     reportdocument report = new reportdocument();      report.load(system.configuration.configurationmanager.appsettings["report_basis"]);       console.writeline("set parameters...");     report.setparametervalue("id", stoerungid);     report.setparametervalue("version", version);      report.setdatabaselogon("user","...");      string export_filename = system.configuration.configurationmanager.appsettings["report_export_prefix"] + stoerungid + ".pdf";      console.writeline("export report {0}", export_filename);     report.exporttodisk(exportformattype.portabledocformat, export_filename);     report.close(); } 

works fine on dev-machine. deploy exe including crystal runtime file target machine logon-errors.

warning: orb::boa_init: hostname lookup returned `localhost' (127.0.0.1/::1) use -oahost option select other hostname set parameters... export report ...\stoerung_6561.pdf unhandled exception: crystaldecisions.crystalreports.engine.logonexception: date nbankanmeldung fehlgeschlagen. ---> system.runtime.interopservices.comexception: datenbankanmeldung fehlgeschlagen. @ ...

it says "database logon failed". thought database connection stored in report? removing subreports didnt help. used crystal report runtime, downloaded sap-website.

it c# 4.5 in vs2012 , crystal report 2008.

any thoughts? whats going wrong? correct way handle this??? highly welcome...

update: edited code gives same logon-error before:

static void runreport(int stoerungid, string version) {     reportdocument report = new reportdocument();      console.writeline("load report {0}", system.configuration.configurationmanager.appsettings["report_basis"]);     report.load(system.configuration.configurationmanager.appsettings["report_basis"]);      foreach (crystaldecisions.shared.iconnectioninfo ci in report.datasourceconnections) {         console.writeline("iconnnectioninfo: servername: {0}, databasename: {1}", ci.servername, ci.databasename);         ci.setconnection("dbserver", "initialcatalog",                          "user","passwd");     }      console.writeline("set parameters...");     report.setparametervalue("stoerungid", stoerungid);     report.setparametervalue("version", version);      string export_filename = system.configuration.configurationmanager.appsettings["report_export_prefix"] + stoerungid + ".pdf";      console.writeline("export report {0}", export_filename);     report.exporttodisk(exportformattype.portabledocformat, export_filename);     report.close(); } 

why don't use approach without storing connections, simple loading in crystalreportviewer table (or whole database) dataset? can done this:

    private void reportform_load(object sender, eventargs e)     {     /*constructor of form*/     configurecrystalreport();     }  private void configurecrystalreports()     {         report = new reportdocument();         /*ds variable strongly-typed dataset, created in program.     in many cases created dragging fields project datasources    in visual studio on  form  designer. instead, created manually using    xsd. exe, included in  .net framework.  created schema file using     sqldataadapter.fillschema method ,     databaseschema.xsd file created class of strongly-typed dataset. then,    in usings  added  using xsdschema.namespace; , in report designer    able select dataset right click on database fields    -> project data -> ado.net datasets*/         typedds ds;         ds = classstoringyourdata.typeddataset;         /*here report file storing location specified */         string reportpath = application.startuppath + "\\" + "crystalreport1.rpt";         report.load(reportpath);         report.setdatasource(ds);          crystalreportviewer1.reportsource = report;     } 

upd. well, if no dataset can stored in memory, may try storing report connection paramters this:

 public reportform()     {      /*form constructor */       initializecomponent();          // initializing of string variables of datasource, username, password         datasource=  "...";          initcatalog = "...";          username =  "...";         pass = "...";        /*this code setting credentials connect database*/  foreach (         crystaldecisions.shared.iconnectioninfo ci in crystalreport11.datasourceconnections)         {             crystalreport11.datasourceconnections.clear();              ci.setconnection(datasource, initcatalog, username, pass);         }      } 

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 -