Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. IN CRYSTAL REPORT OUTPUT EACH RECORD APPEARS 3 0r 4 TIMES REPEATING

IN CRYSTAL REPORT OUTPUT EACH RECORD APPEARS 3 0r 4 TIMES REPEATING

Scheduled Pinned Locked Moved ASP.NET
csharpdatabasehelpasp-netsql-server
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mavii
    wrote on last edited by
    #1

    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(); }

    M 1 Reply Last reply
    0
    • M mavii

      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(); }

      M Offline
      M Offline
      mohankatari
      wrote on last edited by
      #2

      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.

      M 1 Reply Last reply
      0
      • M mohankatari

        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.

        M Offline
        M Offline
        mavii
        wrote on last edited by
        #3

        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)

        M 1 Reply Last reply
        0
        • M mavii

          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)

          M Offline
          M Offline
          mohankatari
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups