Problem description:
Recently, it involves crystal report development. The original system already has some Crystal Reports, which are placed inServer.Server BExtract data, a new website is now created, located on the serverServer C, You needServerIn the Crystal Report on the websiteWebThe load is displayed on the page. Structure:
Development Environment: Vs2008, Crystal Report 2008, Windows2003Domain environment
Solution:
1,AnalysisServerRequired for extracting data from the crystal reportODBCBecauseServerThe crystal report in is fromServer BTo extract dataServerRequiredODBCData Source pointServer BIn the database, this work has been completed by the initial creation of the crystal report, here We need to analyze its data source andServer CCreateODBCReference for data sources(Both settings must be consistent).
First, view the data source used by the server a crystal report.
Go to serverODBCConfigure to analyze the data source
2,InServer CCreate a virtual directory in IIS on the website. ReferenceServerThe folder location of the crystal report.
3,SetServer CMediumODBCData source. The settings here should beServerTheODBCThe corresponding settings are the same. PointServer C.
4,InASP. NETCode. The Code is as follows::
Protected Void Btnsd1ctx_click ( Object Sender, eventargs E)
{
String Repfilepathremoteparamsctx2 = System. Web. httpcontext. Current. server. mappath ( " ../Crystal/crystal report test. rpt " );
Datetime dtime = New Datetime (); // Here, dtime is the parameter that needs to be input by the test Crystal Report.
Try
{
Dtime = Convert. todatetime (txtbxparam. Text. tostring (). Trim ());
}
Catch (Exception ex)
{
String Ke = Ex. tostring ();
}
This . Crystalreportsource1.reportdocument. Load (repfilepathremoteparamsctx2 );
// Note: nexussql is the ODBC connection name set in the preceding ODBC settings,
This . Crystalreportsource1.reportdocument. setdatabaselogon ( " Userid " , " Password " , " Nexussql " , " Database Name " );
This . Crystalreportsource1.reportdocument. setparametervalue ( " Dateraised " , Dtime ); // Input parameters
This . Crystalreportsource1.databind ();
This . Crystalreportviewer1.reportsource = This . Crystalreportsource1;
Crystalreportviewer1.autodatabind= False;
This. Crystalreportviewer1.databind ();
Crystalreportviewer1.bestfitpage= True;
}