IN CRYSTAL REPORT OUTPUT EACH RECORD APPEARS 3 0r 4 TIMES REPEATING
-
i have designed crystal reports in my project in VISUAL STUDIO.net 2005 in ASP.net, C#. i have designed database in SQL Server 2005.in crystal report i have used the SQL Query which takes records from two tables, but in output the record against the column of one table re repeating.i am also displaying my code behind crystalReportViewer1_Load as i am struggling for many days but couldnt find error, please help me find any solution.i have generated reports through crystal report wizard private void crystalReportViewer1_Load(object sender, EventArgs e) { //string strcon = "Provider=SQLOLEDB;Server=./SQLEXPRESS;DataSource=rescue15; User Instance=false; Integrated Security=true;"; string strcon = "Provider=SQLOLEDB;Server=(local);Database=rescue15;uid=sa;pwd=SASA;"; OleDbConnection conn = new OleDbConnection(strcon); //string q = "SELECT DISTINCT crime_mgmt.cr_location,crime_mgmt.cr_date,offensive_issue.c_desc FROM crime_mgmt,offensive_issue WHERE crime_mgmt.fir_num = offensive_issue.fir_num AND crime_mgmt.cr_date BETWEEN '" + crimewithdate.text + "' AND '" + crimewithdate.text1 + "'"; string q = "SELECT c.cr_date, c.cr_location, o.c_desc FROM crime_mgmt AS c INNER JOIN offensive_issue AS o ON c.fir_num = o.fir_num WHERE c.cr_date BETWEEN '" + crimewithdate.text.ToString() + "' AND '" + crimewithdate.text1.ToString() + "'"; OleDbCommand cmd = new OleDbCommand(q, conn); conn.Open(); ReportDocument rep = new ReportDocument(); string exename = Application.ExecutablePath; FileInfo exefile = new FileInfo(exename); string directory = exefile.DirectoryName; string str = HostingEnvironment.ApplicationPhysicalPath + directory + "\\CrystalReport2.rpt"; rep.Load(str); DataSet ds = new DataSet(); OleDbDataAdapter da = new OleDbDataAdapter(cmd); //da.Fill(ds); da.Fill(ds, "crime_mgmt"); da.Fill(ds, "offensive_issue"); //ds.WriteXml(directory + "\\AuthoritesWise.xml"); //ds.ReadXml(directory + "\\AuthoritesWise.xml"); rep.SetDataSource(ds); crystalReportViewer1.ReportSource = rep; conn.Close(); }
-
i have designed crystal reports in my project in VISUAL STUDIO.net 2005 in ASP.net, C#. i have designed database in SQL Server 2005.in crystal report i have used the SQL Query which takes records from two tables, but in output the record against the column of one table re repeating.i am also displaying my code behind crystalReportViewer1_Load as i am struggling for many days but couldnt find error, please help me find any solution.i have generated reports through crystal report wizard private void crystalReportViewer1_Load(object sender, EventArgs e) { //string strcon = "Provider=SQLOLEDB;Server=./SQLEXPRESS;DataSource=rescue15; User Instance=false; Integrated Security=true;"; string strcon = "Provider=SQLOLEDB;Server=(local);Database=rescue15;uid=sa;pwd=SASA;"; OleDbConnection conn = new OleDbConnection(strcon); //string q = "SELECT DISTINCT crime_mgmt.cr_location,crime_mgmt.cr_date,offensive_issue.c_desc FROM crime_mgmt,offensive_issue WHERE crime_mgmt.fir_num = offensive_issue.fir_num AND crime_mgmt.cr_date BETWEEN '" + crimewithdate.text + "' AND '" + crimewithdate.text1 + "'"; string q = "SELECT c.cr_date, c.cr_location, o.c_desc FROM crime_mgmt AS c INNER JOIN offensive_issue AS o ON c.fir_num = o.fir_num WHERE c.cr_date BETWEEN '" + crimewithdate.text.ToString() + "' AND '" + crimewithdate.text1.ToString() + "'"; OleDbCommand cmd = new OleDbCommand(q, conn); conn.Open(); ReportDocument rep = new ReportDocument(); string exename = Application.ExecutablePath; FileInfo exefile = new FileInfo(exename); string directory = exefile.DirectoryName; string str = HostingEnvironment.ApplicationPhysicalPath + directory + "\\CrystalReport2.rpt"; rep.Load(str); DataSet ds = new DataSet(); OleDbDataAdapter da = new OleDbDataAdapter(cmd); //da.Fill(ds); da.Fill(ds, "crime_mgmt"); da.Fill(ds, "offensive_issue"); //ds.WriteXml(directory + "\\AuthoritesWise.xml"); //ds.ReadXml(directory + "\\AuthoritesWise.xml"); rep.SetDataSource(ds); crystalReportViewer1.ReportSource = rep; conn.Close(); }
Hi mavii, I too worked on Crystal Reports where I didnot do the Procedure as given by you. I used Stored Procedures which is very simple and easy to use. If you require this I will help regarding this.
-
Hi mavii, I too worked on Crystal Reports where I didnot do the Procedure as given by you. I used Stored Procedures which is very simple and easy to use. If you require this I will help regarding this.
-
i have not worked with stored procedure, please guide me, can u tell me the whole procedure to design crystal reports in windows application (not the web-based application)
Hi, I worked in Web application but I think both are the same. The procedure which I did in Web Applications is: 1) First in the ASPX Page gave the required Text boxes which will give input to Stored Porcs. Upon submitting the Page I will redirect to new ASPX Page which will Display only Crystal Reports. This is because if we keep any other fields like Textboxes there will be a problem which I don't know exactly. 2) In the Second Page I will just have Crystal Reports Viewer(CRViewerPortfolioReports) and Crystal Reports Source(CRSourcePortfolioReports;). On Page Load the below code has to be written int Portfolio_ID = int.Parse(Request.QueryString.Get("Portfolio_ID")); //Portfolio_ID Input Parameter for Stored Procedure. string ReportName = "CRPortfolioReports.rpt"; string ReportPath; ReportPath = Server.MapPath("../CrystalReportFiles/") + ReportName; //ReportPath Location of the CRYSTAL REPORT CRSourcePortfolioReports.ReportDocument.Load(ReportPath); CRSourcePortfolioReports.ReportDocument.SetDatabaseLogon(USERNAME, PASSWORD); CRSourcePortfolioReports.ReportDocument.SetParameterValue("@IMRsPerPortfolio_PortfolioID", Portfolio_ID); //@IMRsPerPortfolio_PortfolioID STORED PROCEDURE INPUT PARAMETER //IF you want to add another Input Parameter DATE... //CRSourcePortfolioReports.ReportDocument.SetParameterValue("@IMRsPerPortfolio_DATE", //DATE); CRViewerPortfolioReports.ReportSource = CRSourcePortfolioReports; CRViewerPortfolioReports.DataBind(); 3) Building the CRYSTAL REPORT .rtp FILE Add New Crystal Report File and create a new Database connection and add the Stored Procedure developed. You will automatically get the Input Parameters and Output Parameters which you could automatically map to X or Y Cordinates. Like if @IMRsPerPortfolio_PortfolioID id INPUT Parameter it will be coming in Parameters Field of Field Explorer Tab.