Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello every One,
I am using Microsoft Report Viewer under VS2008.
I have following problems in reporting [ Windows Forms Application]

1.
Can I make reports without using any DataSet.xsd file ?
2.
How can I specify database path at run time for reports, because it will change on user's computer. I don't want to store it in connection string in .config or any file. Also ConnectionString contains password for database.
3.
For 5 Reports I think single report viewer control on a form will do this, and 5 different .rdlc files will be required ,
but how many DataSet.xsd files do I need to create? [If I use].
4.
I created one Dataset1.xsd file, added one Table adapter ,
That started configuration wizard then I followed whole thing, wrote query & Finish etc.
But it asks to store connection string ...... I don't want it.
If I don't store how to achieve Reporting?
I created DataSet1.xsd file , just to draw fields on Report1.rdlc , then I want to forget this.
I use following code to show report at run time.

private void button1_Click(object sender, EventArgs e)
{
    SqlCeConnection con=new SqlCeConnection("Data Source=" +
    Global.MyAppPath + @"\Database\CityPride.sdf;password=xyz");
    con.Open();
    DataSet ds=new DataSet("login"); // probably any string
    SqlCeDataAdapter da=new SqlCeDataAdapter ("select * from login",con);

    da.Fill(ds,"Login"); // why should I need to give table name Login here , if                                    I already mentioned it in query, may be I will need data from multiple tables then?

    ReportDataSource rds = new ReportDataSource();
    rds.Name = "login"; // probably any string
    rds.Value = ds.Tables[0];
    reportViewer1.LocalReport.ReportPath = "..\\..\\Reports\\Report1.rdlc";
    reportViewer1.LocalReport.DataSources.Clear();
    reportViewer1.LocalReport.DataSources.Add(rds);
    reportViewer1.Refresh();
    reportViewer1.RefreshReport();
}
Does not work what is wrong?
It gives error:-
a data source instance has not been supplied for the data source DataSet1_Login

Please Help, Thanks.

[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 10-Mar-11 2:39am
v3

The answer for your question comment in line "da.Fill(ds, "Login"); is that a dataset may contain multiple tables. And your 'da' that represents to SqlDataAdapter works to just add DataTables to dataset, its not related to your query any way.

In your query you can use multiple table as you asked but before that you have to add all tables to dataset through SqlDataAdapter.
 
Share this answer
 
1.- You need a DataSet to bind each filed to the report.
2.-
reportViewer1.LocalReport.ReportPath = strYourPath;
you //You could change this in runtime, you have to use a variable.
3.- If all the reports are totally different, yes you need each DataSet to bind each Report.
4.- The connection string is requiered in the design just to load data with VisualStudio. You are using rdlc files that means that you are going to process your report in a Server.
If you usr rdl files you will need to process your reports in your Client, in this case you'll need to pass the DataSet directly.

http://www.gotreportviewer.com/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900