none
How do i create Reports using Report1.rdlc and ReportViewer in C#?

    Question

  • Hi Guys, I am total a newbie in creating reports my damn prof never taught us in school how to create reports. anyway i wanna know how can i design my report1.rdlc hardcoded not through the wizard. and plus how do i create customized query from my sql database and pass the values in a table form of my report template. i need to begin step by step. i was kinda able to perform reports in a single form using the wizard but what i need is I have to do it in code so that i'd know how the process is going on besides i need to pass customized queries. please help me how do i create a dataset, datasource and how to pass query to the datasource. since i need to deploy this program i am using Environment.MachineName; for my connstring computer name so that the program will run in any computer without manipulating the connstring, i am wondering if im gonna create reports through the wizard my program is gonna mess in conducting connection with the database because the wizard chooses path for the connstring and creating dataset.

     

    hoping for your kind considerations.

    i ll appreciate your concerns with regard to my problem.

    Monday, July 19, 2010 6:08 PM

Answers

  • Hi Maf Fereydouni,

       Welcome to MSDN forums! I'm glad to see your active participation and discussion in MSDN forums. Based on your description and above code if you define your sql query statement can return results ,I think you may missed create report object please refer to full example the link below:

       Creating Crystal Reports using C# with Datasets http://www.codeproject.com/KB/cs/CreatingCrystalReports.aspx  Hope these will help you!  

     

       If you still have any doubt and concern about this issue, please let me know. If I misunderstood you, please kindly elaborate your question.

     This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet


    Please Mark as Answered If this is helpful Or Un-Mark as Answered if it is not helpful.

    Best Regards,
    Yan Jun
    Microsoft Online Community Support

    Wednesday, July 21, 2010 9:01 AM
    Moderator

All replies

  • any concern with my code? i used crystal. but i cant pass my querry to the crystalreport1.rpt

     

                    connection.Open();

                    string sqlstatement = "SELECT * FROM InventoryStocks WHERE Stocks <= MinStock";

                    SqlCommand command = new SqlCommand();

                    command.Connection = connection;

                    command.CommandText = sqlstatement;

                    SqlDataAdapter da = new SqlDataAdapter(command);

                    DataSet1 ds = new DataSet1();

                    ReportDocument cryRpt = new ReportDocument();

                    da.Fill(ds, "DataTable1");

                    objRpt.SetDataSource(ds.Tables[1]);

                    crystalReportViewer1.ReportSource = objRpt;

                    crystalReportViewer1.Refresh();

    Monday, July 19, 2010 9:17 PM
  • Hi Maf Fereydouni,

       Welcome to MSDN forums! I'm glad to see your active participation and discussion in MSDN forums. Based on your description and above code if you define your sql query statement can return results ,I think you may missed create report object please refer to full example the link below:

       Creating Crystal Reports using C# with Datasets http://www.codeproject.com/KB/cs/CreatingCrystalReports.aspx  Hope these will help you!  

     

       If you still have any doubt and concern about this issue, please let me know. If I misunderstood you, please kindly elaborate your question.

     This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet


    Please Mark as Answered If this is helpful Or Un-Mark as Answered if it is not helpful.

    Best Regards,
    Yan Jun
    Microsoft Online Community Support

    Wednesday, July 21, 2010 9:01 AM
    Moderator