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. General Programming
  3. C#
  4. problem in generating crysatl reports

problem in generating crysatl reports

Scheduled Pinned Locked Moved C#
cssdatabasesysadminhelp
15 Posts 5 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 monuSaini

    Hello Edwin, Thanks for ur rply. But still same problem. It is showing all the records. If I am using only this crystalReportViewer1.ReportSource = NewReport; then also it is showing all the records. Rregards, rahul saini

    E Offline
    E Offline
    Edwin Syarief
    wrote on last edited by
    #6
    SqlDataAdapter adapter = new SqlDataAdapter(yourQuery, conn);
    DataSet ds = new DataSet();
    DataTable dt = new DataTable("tablename");
    adapter.Fill(dt);
    ds.Tables.Add(dt);
    ds.WriteXml("C:\text.xml");
    

    Then On your crystal report Database Fields: change your dataset with "text.xml" If U have finish it, then create a dataset with your query, then change the code like this:

    SqlDataAdapter adapter = new SqlDataAdapter(yourQuery, conn);
    DataSet ds = new DataSet("YourDataSet");
    DataTable dt = new DataTable("tablename");
    adapter.Fill(dt);
    ds.Tables.Add(dt);
    
    ReportDocument rd = new ReportDocument();
    rd.SetDataSource = ds;
    crystalReportViewer1.ReportSource = rd;
    

    Regard, Edwin

    M 2 Replies Last reply
    0
    • M monuSaini

      Hello Tomi, Thanks for ur rply. Its int. Regards, rahul saini

      T Offline
      T Offline
      T EDY
      wrote on last edited by
      #7

      Hi Rahul, I wonder if u want to show the data if the age is above 50 right? if u use query: SELECT * FROM Your_Table Where age < 50 u got an output data age below 50, if u want to show the data where age is more than 50 than u must change your query into : SELECT * FROM Your_Table WHERE age > 50 i try to my query analizer thats work:) Regard, Tomi

      E 1 Reply Last reply
      0
      • T T EDY

        Hi Rahul, I wonder if u want to show the data if the age is above 50 right? if u use query: SELECT * FROM Your_Table Where age < 50 u got an output data age below 50, if u want to show the data where age is more than 50 than u must change your query into : SELECT * FROM Your_Table WHERE age > 50 i try to my query analizer thats work:) Regard, Tomi

        E Offline
        E Offline
        Edwin Syarief
        wrote on last edited by
        #8

        TomiEdy wrote:

        if u use query: SELECT * FROM Your_Table Where age < 50 u got an output data age below 50, if u want to show the data where age is more than 50 than u must change your query into : SELECT * FROM Your_Table WHERE age > 50

        I think U right Tomi, maybe U must check your query Rahul Regard, Edwin

        T 1 Reply Last reply
        0
        • E Edwin Syarief

          TomiEdy wrote:

          if u use query: SELECT * FROM Your_Table Where age < 50 u got an output data age below 50, if u want to show the data where age is more than 50 than u must change your query into : SELECT * FROM Your_Table WHERE age > 50

          I think U right Tomi, maybe U must check your query Rahul Regard, Edwin

          T Offline
          T Offline
          T EDY
          wrote on last edited by
          #9

          Thank You Edwin Regard, Tomi

          1 Reply Last reply
          0
          • E Edwin Syarief
            SqlDataAdapter adapter = new SqlDataAdapter(yourQuery, conn);
            DataSet ds = new DataSet();
            DataTable dt = new DataTable("tablename");
            adapter.Fill(dt);
            ds.Tables.Add(dt);
            ds.WriteXml("C:\text.xml");
            

            Then On your crystal report Database Fields: change your dataset with "text.xml" If U have finish it, then create a dataset with your query, then change the code like this:

            SqlDataAdapter adapter = new SqlDataAdapter(yourQuery, conn);
            DataSet ds = new DataSet("YourDataSet");
            DataTable dt = new DataTable("tablename");
            adapter.Fill(dt);
            ds.Tables.Add(dt);
            
            ReportDocument rd = new ReportDocument();
            rd.SetDataSource = ds;
            crystalReportViewer1.ReportSource = rd;
            

            Regard, Edwin

            M Offline
            M Offline
            monuSaini
            wrote on last edited by
            #10

            Hello Edwin, When i m writing the xml it is giving me following error. ds.WriteXml("C:\text.xml"); Illegal characters in path. Regards, rahul saini

            P 1 Reply Last reply
            0
            • M monuSaini

              Hello Every body, I am new with crystal reports. I want to generate report for those employees whose age is more than 50 yrs. But I am not able to do so .It is showing all the records. I had added an crystal report in my project. I link it with the database through wizard only, On form1 it had inserted an crystal report viewer. on the load event of the form1 I had used the following code but it is use less. SqlConnection Connection = new SqlConnection("server='server1'; user id='sa'; password='admin'; database='employee'"); SqlCommand myCommand = new SqlCommand("SELECT * from companyEmp where age < '50'"); myCommand.Connection = Connection; myCommand.CommandType = CommandType.Text; SqlDataAdapter DA = new SqlDataAdapter(); DA.SelectCommand = myCommand; DataSet DS = new DataSet(); DA.Fill(DS); crystalReportViewer1.SetDataSource(DS.Tables[0]); crystalReportViewer1.ReportSource = objNewReport; But it is still showing all the record of companyEmp. Regards, rahul saini

              D Offline
              D Offline
              Developer611
              wrote on last edited by
              #11

              Hi there . Look my friend you set you ReportViewer data source it's wrong . you must create new instance of your CrystalReport.rpt file . for example i have an report file named report.rpt . // Create new instance of your CrystalReport File Report _Report = new Report(); // Set Report data source ,no your viewer . _Report.SetDataSource(Your_DataSource); // Finally set your report viewer report source to your Report file . crystalReportViewer1.ReportSource = _Report;

              DMASTER

              M 1 Reply Last reply
              0
              • D Developer611

                Hi there . Look my friend you set you ReportViewer data source it's wrong . you must create new instance of your CrystalReport.rpt file . for example i have an report file named report.rpt . // Create new instance of your CrystalReport File Report _Report = new Report(); // Set Report data source ,no your viewer . _Report.SetDataSource(Your_DataSource); // Finally set your report viewer report source to your Report file . crystalReportViewer1.ReportSource = _Report;

                DMASTER

                M Offline
                M Offline
                monuSaini
                wrote on last edited by
                #12

                Hi, I had use this also but again it is showing the same result.(all the records are showing) this the code i m using SqlConnection Connection = new SqlConnection("server='sName'; user id='sa'; password='admin'; database='employee'"); SqlDataAdapter DA = new SqlDataAdapter("SELECT empId,empName,empAge from companyEmp where age < 50", Connection); DataSet DS = new DataSet(); DA.Fill(DS); newReport objNewReport = new newReport(); objNewReport.SetDataSource(DS.Tables[0]); crystalReportViewer1.ReportSource = objNewReport ; Regards, rahul saini

                D 1 Reply Last reply
                0
                • M monuSaini

                  Hello Edwin, When i m writing the xml it is giving me following error. ds.WriteXml("C:\text.xml"); Illegal characters in path. Regards, rahul saini

                  P Offline
                  P Offline
                  PhilDanger
                  wrote on last edited by
                  #13

                  ds.WriteXml("C:\text.xml"); -- \t is the character code for a tab. You need to escape your backslashes by... using another backslash. ds.WriteXml("C:\\text.xml");

                  1 Reply Last reply
                  0
                  • M monuSaini

                    Hi, I had use this also but again it is showing the same result.(all the records are showing) this the code i m using SqlConnection Connection = new SqlConnection("server='sName'; user id='sa'; password='admin'; database='employee'"); SqlDataAdapter DA = new SqlDataAdapter("SELECT empId,empName,empAge from companyEmp where age < 50", Connection); DataSet DS = new DataSet(); DA.Fill(DS); newReport objNewReport = new newReport(); objNewReport.SetDataSource(DS.Tables[0]); crystalReportViewer1.ReportSource = objNewReport ; Regards, rahul saini

                    D Offline
                    D Offline
                    Developer611
                    wrote on last edited by
                    #14

                    Wow , I got it .you are using untyped dataset , right ? look answer to my question I hope, I can help you . 1: Did you put any typed dataset in your report form ? 2: Did you used directly connection in report ? Send your email address to my mail : www.Developermaster61@gmail.com I hope, I elaborate in more detail .

                    DMASTER

                    1 Reply Last reply
                    0
                    • E Edwin Syarief
                      SqlDataAdapter adapter = new SqlDataAdapter(yourQuery, conn);
                      DataSet ds = new DataSet();
                      DataTable dt = new DataTable("tablename");
                      adapter.Fill(dt);
                      ds.Tables.Add(dt);
                      ds.WriteXml("C:\text.xml");
                      

                      Then On your crystal report Database Fields: change your dataset with "text.xml" If U have finish it, then create a dataset with your query, then change the code like this:

                      SqlDataAdapter adapter = new SqlDataAdapter(yourQuery, conn);
                      DataSet ds = new DataSet("YourDataSet");
                      DataTable dt = new DataTable("tablename");
                      adapter.Fill(dt);
                      ds.Tables.Add(dt);
                      
                      ReportDocument rd = new ReportDocument();
                      rd.SetDataSource = ds;
                      crystalReportViewer1.ReportSource = rd;
                      

                      Regard, Edwin

                      M Offline
                      M Offline
                      monuSaini
                      wrote on last edited by
                      #15

                      Hello Edwin, One of my friend had told me that this issue can be resolved through SELECT EXPERT. Do you had any idea about this. Regards, rahul saini

                      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