Visual Studio Development Bookmark and Share   
 index > Crystal Reports for Visual Studio > crystal report in dataSet
 

crystal report in dataSet

I would like to do a report on some of my data which I have stored into dataSet. This is the code I got:

private void CopyOut_Load(object sender, EventArgs e)
        {
            string p = ConfigurationManager.ConnectionStrings["povezava"].ConnectionString;
            povezava = new SqlConnection(p);

            DataSet dataSet = new DataSet();
            SqlDataAdapter dataAdapter = new SqlDataAdapter("SELECT Ime, Priimek, Stacionarni, Mobilni FROM Osebe", povezava);
            dataAdapter.Fill(dataSet, "Osebe");

            CrystalDecisions.CrystalReports.Engine.ReportDocument myCR = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            myCR.SetDataSource(dataSet); //HERE I got an error
            crystalReportViewer1.ReportSource = myCR;
        }


I got an error:Invalid report file path.


Is it something wrong with:
CrystalDecisions.CrystalReports.Engine.ReportDocument myCR = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
It has to be, but I don`t know what else to do, so I am asking for a bit of a help. 
Thank you!

I am a rookie at C#, so please don`t be mad if my questions gonna sound stupid...
  • Moved byLing WangMSFTFriday, October 16, 2009 7:31 AM (From:Windows Forms General)
  •  
Mitja Bonca  Thursday, October 15, 2009 12:15 PM
Got it! it`s fine!
I would just like to know if there is a way to put 2 dataSets into one crystalReport?
But as far as I have seen, it is not possible. Am I wrong?

I am a rookie at C#, so please don`t be mad if my questions gonna sound stupid...
  • Marked As Answer byMitja Bonca Friday, October 16, 2009 9:09 AM
  •  
Mitja Bonca  Thursday, October 15, 2009 9:36 PM

Before setting DataSource you have to Load the Crystal Report File (.rpt) file.

myCR.Load("FileName.rpt");


If you haven't create then you can use following steps

http://www.codeproject.com/KB/cs/Crystal_Report.aspx


Gaurav Khanna
Khanna Gaurav  Thursday, October 15, 2009 12:31 PM
I put the crystal Report file in my project. Did as you said, inserted:(myCR.Load("CrystalReport1.rpt");  
but now I got an error on this line: Load report faild. 

I would like manualy inserted all the data needed in the report. I dont want to do as it is on the codeproject.com webiste (on your link you gave me).


btw, I was thinking to use these option:

Why I these then for, if I need to add new item, like it`s shown on that codeproject.com website example?

I am a rookie at C#, so please don`t be mad if my questions gonna sound stupid...
Mitja Bonca  Thursday, October 15, 2009 12:51 PM
I got this code:
// code to get data from the DB
DBConnection DBConn = new DBConnection();
OleDbDataAdapter myDataAdapter = DBConn.getDataFromDB();

// use the created Dataset to fill it with data got
// from the DB by using the DataAdapter
DataSet dataReport = new DataSet();
myDataAdapter.Fill(dataReport,"myPersonalInfoTable");
// create a new report from the created CrystalReport
myDataReport myDataReport = new myDataReport();  //THIS IS WHAT I DON`T GET IT!!

// set the data source of the report
myDataReport.SetDataSource(dataReport);  

// set the report source of the created “crystalReportViewer”
// component to the created report
crystalReportViewer1.ReportSource = myDataReport;


How he got that line? I can`t do it.

I am a rookie at C#, so please don`t be mad if my questions gonna sound stupid...
Mitja Bonca  Thursday, October 15, 2009 5:27 PM
Got it! it`s fine!
I would just like to know if there is a way to put 2 dataSets into one crystalReport?
But as far as I have seen, it is not possible. Am I wrong?

I am a rookie at C#, so please don`t be mad if my questions gonna sound stupid...
  • Marked As Answer byMitja Bonca Friday, October 16, 2009 9:09 AM
  •  
Mitja Bonca  Thursday, October 15, 2009 9:36 PM

You can use google to search for other answers

Custom Search

More Threads

• Crystal Report 10 and VS2005 Deployment Issues
• Crystal Report Programs
• Crystal reports in windows service application
• Unable to find report in the mainfest resources
• Large text field problems with PDF export in VS 2005 version
• Anyone ever worked with Tobit Faxware?
• Formula Returning a operation divided by zero...
• How do I simply create a report showing 2 pages
• CrytalReportViewer 11 not appearing in Toolbox in VS 2008
• Dynamic Column Sorting in Crystal Report