c# - Dynamic Logon parameters in Crystal report 9 with 2 different database -
i have problem having 2 database in 1 crystal report.
i found article , use one: http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-dynamic-login.htm
is working if using 1 database need connect other database information , found out not working..
i have modification code , goes this:
reportdocument crreportdocument = new reportdocument(); sections crsections; reportdocument crsubreportdocument; subreportobject crsubreportobject; reportobjects crreportobjects; connectioninfo crconnectioninfo; //connectioninfo crconnectioninfo1; database crdatabase; tables crtables; tablelogoninfo crtablelogoninfo; crreportdocument.load(httpcontext.current.server.mappath("~/reports/" + filename)); crdatabase = crreportdocument.database; crtables = crdatabase.tables; string connectstring = configurationmanager.connectionstrings["conntranscript"].connectionstring; sqlconnectionstringbuilder builder = new sqlconnectionstringbuilder(connectstring); crconnectioninfo = new connectioninfo(); crconnectioninfo.servername = builder.datasource; crconnectioninfo.databasename = builder.initialcatalog; crconnectioninfo.userid = builder.userid; crconnectioninfo.password = builder.password; foreach (crystaldecisions.crystalreports.engine.table atable in crtables) { crtablelogoninfo = atable.logoninfo; crtablelogoninfo.connectioninfo = crconnectioninfo; atable.applylogoninfo(crtablelogoninfo); } crsections = crreportdocument.reportdefinition.sections; foreach (crystaldecisions.crystalreports.engine.section crsection in crsections) { crreportobjects = crsection.reportobjects; foreach (reportobject crreportobject in crreportobjects) { if (crreportobject.kind == reportobjectkind.subreportobject) { crsubreportobject = (subreportobject)crreportobject; crsubreportdocument = crsubreportobject.opensubreport(crsubreportobject.subreportname); crdatabase = crsubreportdocument.database; crtables = crdatabase.tables; foreach (crystaldecisions.crystalreports.engine.table atable in crtables) { crtablelogoninfo = atable.logoninfo; crtablelogoninfo.connectioninfo = crconnectioninfo; atable.applylogoninfo(crtablelogoninfo); } } } } crreportdocument.verifydatabase();
that connection first database how connect other database..
here image of crystal report:
the image
came other database , details other database too.
how solve problem?
any suggestion appreciated. thank much.
Comments
Post a Comment