Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

setting datasource for strongly typed report object

Posted on 2008-10-02
5
Medium Priority
?
412 Views
Last Modified: 2013-12-17
I can successfully get the application to display the report correctly via the snippet below.  This requires me to have the report file directly on the file system.  I have the report itself set as an embedded resource in the report's properties.  I would much rather be able to distribute the app without having to include the RPT file itself.  I figured if I made it a strongly typed report (hopefully I'm using the correct terminology), I could then simply set the report object to the datasource, I should be okay ... but I can't seem to figure out how to set the datasource property for the report object.  The code that I was trying is within the commented block in the snippet.  If I try to run it as is, the application will load ... but it just gets no data.

Any help is appreciated!   Thanks!
private void Form1_Load(object sender, EventArgs e)
        {
            this.SuperVTableAdapter.Fill(this.dsMSA.SuperV);
            this.GuestsTableAdapter.Fill(this.dsMSA.Guests);
            this.PatronsTableAdapter.Fill(this.dsMSA.Patrons);
 
            
            docRPT.Load(Application.StartupPath + "\\SuperVReport.rpt");
            docRPT.SetDataSource(dsMSA);
            crystalReportViewer1.ReportSource = docRPT;
            
            /*
            EMSA EMSARPT = new EMSA();
            crystalReportViewer1.ReportSource = EMSARPT;
            */
        }

Open in new window

0
Comment
Question by:trs28
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 22631199
Your code is using the external report rather than the embedded one.

I forget the proper calling code since I don't use it.  I looked for the code on the Crystal site and didn't find it.

You have to declare an object to be of the type of the report.  I believe like you are doing in lines 13-14.

mlmcc
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 22634695
Mike,

That would be something like this:

BatchDelivery report = new BatchDelivery();
report.DataSource = this.GetBatchDataSet(DateTime.Now);
this.ReportViewer.ReportSource = report;
0
 

Author Comment

by:trs28
ID: 22635294
Mike, in my snipped, the code that isn't commented functions just as I need it to ...as long as I include the file.   I have the file added to my project and set to be an embedded resource, but by using the ReportDocument model, I have to access the file off of the file system.  There doesn't seem to be anyway to reference the embedded report.  That's seems to be the case on everything I've researched about this.  
The code in my snippet that is commented is the way I want to make the app work.

TheLearnedOne, at first, I tried exactly what you have listed there for your second line.  The only thing is... there is no DataSource property.  The only thing I have is "Database", "DataDefinition", and "DataSourceConnections".   ...and I tried to manipulate the last one in a variety of different ways, but it wasn't sticking out to me how to utilize it.

By the way, my project's CrystalDecisions references are version 11.5.3700.0 if that helps any.

Thanks guys!
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 22635715
Typo:

BatchDelivery report = new BatchDelivery();
report.SetDataSource(this.GetBatchDataSet(DateTime.Now));
this.ReportViewer.ReportSource = report;
0
 

Author Comment

by:trs28
ID: 22635902
PERFECT!   That was exactly what I was looking for!   I blows my mind how I missed "SetDataSource" !!

Thanks again!
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question