report viewer and other question

376 views
Skip to first unread message

seferina zend

unread,
Nov 20, 2014, 8:04:05 PM11/20/14
to myfyire...@googlegroups.com
Dear Peter and all majorsilence reporting user, 

Could you please help me for below questions;

1. How to make a report with complete menu i.e there is button print, export to excel or pdf etc. 
Report that is look like report generated with crystal report. Winform viewer that i created does not have it. Or there is something i have to do to make standard report toolbar menu appear.

2. Report that i want to create has a report header for company name and logo. And the report content is from application database. (actually, the company name can be retrieve from database also), how can i get 2 different information from 2 different tables that are not related one each other.

Sorry for asking many question, i do try learning it using trial and error method. But i hope some one can make easier for me to speed up the coding process.

Best Regards
w mardian

 


Kernel Klink

unread,
Nov 21, 2014, 6:37:09 AM11/21/14
to myfyire...@googlegroups.com
Hi,

1.  I am not sure about the menu, however, in the application you can create a button to output the report in a different format. 
MemoryStreamGen ms = new MemoryStreamGen();
ProcessReport pr = new ProcessReport(rdlp.Report, ms);
pr.Run(this.ReportParams, OutputPresentationType.PDF);

2.  I usually pull the relative path to the company logo.  The report then uses that path to find the logo when it is rendered on the web.  Create an additional data set; you can write the query how ever you like; the relationship is up to you.

The Kernel

seferina zend

unread,
Nov 22, 2014, 12:05:39 PM11/22/14
to myfyire...@googlegroups.com
Hi Kernel, 
Many thanks. I will retry to make the report.
But i am so sad because there is very limited resource for step by step tutorial

Thanks and Regards

Peter Gill

unread,
Nov 22, 2014, 2:39:52 PM11/22/14
to myfyire...@googlegroups.com
Take a look at https://github.com/majorsilence/My-FyiReporting/tree/master/Examples/Sample-Report-Viewer.  It is an example of a report viewer and a toolstrip.  It is a work in progress but I think it should point you in the right direction.  Once I am satisfied with it I will turn it into a user control in the RdlViewer project.


https://github.com/majorsilence/My-FyiReporting/wiki/1002---Pass-an-Image-to-a-Report shows how to dynamically pass an image to a report from your code.

seferina zend

unread,
Nov 22, 2014, 3:10:15 PM11/22/14
to myfyire...@googlegroups.com
Dear Peter and kernel, 
Many thanks for your effort. 
Can i ask you one more question;

1. what is the best practice to / How to make a report that has; header (such as; laboratory address, building phone, po box etc) and main report content that retrieved from database. Should i combine all the report fields/entry into a single query?? or i can fill each different section using different query (but how).

If i have to type manually address, po box  etc, i think it will be difficult because the application will be installed in different address..
I did read about this questions in this forum but i could not get clear answer for it.

2. I try to make sub report by following this https://groups.google.com/forum/#!topic/myfyireporting/MWtQTJbgwBQ, but it failed. it seem it can not find the field (foreign key field) in the main report. should foreign key field name start with "fk" or there is something else that i need to do..


Thanks in advance
Best Regards

Kernel Klink

unread,
Nov 22, 2014, 9:41:10 PM11/22/14
to myfyire...@googlegroups.com
1) Generally I try to keep each data set specific to a single entity.  This eliminates complex queries, repeated data and other headaches.  In you example, I would have 1 data set be the Lab info.  Another data set with the actual content. 

As for application design, as part of the install process, I would have the client set the "current laboratory" address.  Then this single table could be referenced for all reports regardless of where the application is deployed.

2) Make sure your query runs; if you are getting a foreign key error, likely your query has an issue.  I am most familiar with MS Sql and MySql, neither require an "fk" for a foreign key.  Perhaps that is just a naming convention from some other site?

Best DB design practices suggest you should create a foreign key relationship, but that is a question for a different forum.  This might help (MS SQL): http://blog.sqlauthority.com/2008/09/08/sql-server-%E2%80%93-2008-creating-primary-key-foreign-key-and-default-constraint/

The Kernel

seferina zend

unread,
Nov 23, 2014, 8:40:31 PM11/23/14
to myfyire...@googlegroups.com
Dear Kernel and all group users
Many thanks for your prompt respond.

1. yes, creating dataset for single entity is simpler and avoiding complex query. One more question for this. How to put database value on the header? 
I already try to use; =First(ReportItems!address.Value), and address is retrieved from report item (address is name of textbox in report content retrieved from database). But when i try to hide the textbox in report content, i was not able to show the data in the header. it is also hidden. :( Can you help how to hide report item and use it in the header part ?? 

2. For sub report, i do not create referenece foreign key in the database, but i just put id of the foreign table in my table, and use it as foreign key on the query. so the table does not related in term of rdbms system. Can it be the cause that my sub report does not work.

Thank in advance
best regards

Kernel Klink

unread,
Nov 23, 2014, 9:10:45 PM11/23/14
to myfyire...@googlegroups.com
1)  I haven't put something dynamic in the header before, but I use the same solution as you for a dynamic footer.  I had the same issue with the footer disappearing and resorted to making the text white in color.  It is not the right solution, but given the time constraints at the time, it had to do.

2) I am not 100% sure I understand what you are describing, but I would recommend that you open the sub report and make sure it runs on its own.  If it does, then most likely it is the passing of parameters from the parent report to the child.

The Kernel

noheli...@gmail.com

unread,
Jan 14, 2015, 3:39:45 PM1/14/15
to myfyire...@googlegroups.com
hi Kernel, how can I to pass parameters from the parent to the child?

I´ve defined parameter in subreport, but how update the parameter value.

Thanks
Message has been deleted

Kernel Klink

unread,
Jan 14, 2015, 9:07:25 PM1/14/15
to myfyire...@googlegroups.com

Images didn't come out in my last post ... reposting ...

-----------------
I don't have any details about your report, so this is based off of a report I have created.  In the subreport I have the following parameters defined:



In the parent report, I have replaced a cell with a sub report and added properties to pass key data to the subreport:





























Let me know if that helps or if it completely missed your question.

The Kernel.


Nohelia Diaz

unread,
Jan 15, 2015, 11:29:59 AM1/15/15
to myfyire...@googlegroups.com
Thank you so much, now I have another question related to RdlViewer, I have a form with RdlViewer and a button click event for show the report, this code doesn't works when I add a subreport, in this case subreport Dataset is a query about detail order, when I try show the report it indicate that are necesaries columns set in the subreport, my question is how do I pass that dataset for subreport? I think that must not be necessary because I am passing parameter from the parent report to subreport

this is my code:
Private Sub ButtonReport_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonSelectReport.Click

Dim connectionString As String = "myconnection"
Dim Order As Integer = TextBox2.Text 'Order Id
Dim s As String 'Query
Dim sda As SqlDataAdapter
Dim dtOrden As DataTable

Using cnn As New SqlConnection(connectionString)
cnn.Open()
Dim cmd As New SqlCommand(s, cnn)
dtOrden = New DataTable()
dtOrden.Columns.Add("Number", Type.GetType("System.String"))
dtOrden.Columns.Add("CodProd", Type.GetType("System.String"))
dtOrden.Columns.Add("Descrip", Type.GetType("System.String"))
sda = New SqlDataAdapter(cmd)
sda.Fill(dtOrden)
End Using

Dim filepath As String = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "Order.rdl")
RdlViewer1.SourceFile = New Uri(filepath)
RdlViewer1.ReportName = "Order"
RdlViewer1.Report.DataSets("Data").SetData(dtOrden)
RdlViewer1.Parameters = "OrderId=" & TextBox2.Text

RdlViewer1.Rebuild()
End Sub

Kernel Klink

unread,
Jan 15, 2015, 6:20:09 PM1/15/15
to myfyire...@googlegroups.com
Architectural question ... what is the reason you are passing in the data set instead of letting the report go out and fetch the data it needs? 

There may be good reasons to pass the data in (e.g. performance), but generally I would try to encapsulate a report so it does not have to rely on the parent code base. 

After understanding your design, I will be able to provide a more targeted answer.

The Kernel

Nohelia Diaz

unread,
Jan 16, 2015, 1:26:52 PM1/16/15
to myfyire...@googlegroups.com
thanks Kernel, you're right, I've changed the form of passing the data and it  works.

nigra...@gmail.com

unread,
Apr 2, 2019, 4:21:33 PM4/2/19
to myfyireporting
In that case, passing dataset to report, How can I use subreports? I have 3 dataset filled, the third replicated into subreport but I don't understand how to use parameters to make right filter on rows of third dataset (subreport)
Reply all
Reply to author
Forward
0 new messages