|
I have tried to do this the whole day, but to no luck.
My report gets the data from:
Me.PrintedJTNTableAdapter.Fill(Me.JTNDataSet.PrintedJTN, frmMain.ToolStripLabel6.Text)
PrintedJTNTableAdapter.GetData(frmMain.ToolStripLabel6.Text)
Me.ReportViewer1.RefreshReport()
All the examples that I can find on how to print the report without viewing te report uses local xml files.
The user needs to print three different reports when they click on print on going the reportviewer way is very long.
PLEASE HELP...
|
|
|
|
|
Here is all the code to export the report to PDF and print the report automatically.
###########################################################################
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If PrintSelect.chkLaser.Checked = True Then
Timer1.Enabled = False
On Error Resume Next
Me.PrintedJTNTableAdapter.Fill(Me.JTNDataSet.PrintedJTN, frmMain.ToolStripLabel6.Text)
PrintedJTNTableAdapter.GetData(frmMain.ToolStripLabel6.Text)
With Me.ReportViewer1
.RefreshReport()
End With
Else
Timer1.Enabled = True
End If
End Sub
Private Sub ReportViewer1_RenderingComplete(ByVal sender As Object, ByVal e As Microsoft.Reporting.WinForms.RenderingCompleteEventArgs) Handles ReportViewer1.RenderingComplete
Dim format As String = "PDF"
Dim deviceInfo As String = Nothing
Dim mimeType As String = Nothing
Dim encoding As String = Nothing
Dim fileNameExtension As String = Nothing
Dim streams As String() = Nothing
Dim warnings As Microsoft.Reporting.WinForms.Warning() = Nothing
Dim returnValue As Byte()
returnValue = ReportViewer1.LocalReport.Render(format, deviceInfo, mimeType, encoding, fileNameExtension, streams, warnings)
Dim fs As New IO.FileStream("c:\a001.pdf", IO.FileMode.Create)
fs.Write(returnValue, 0, returnValue.Length)
fs.Close()
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.Verb = "print"
psi.WindowStyle = ProcessWindowStyle.Hidden
psi.FileName = ("c:\a001.pdf")
Process.Start(psi)
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'res = AcroExchAVDoc.Close(False)
Dim myProcesses As Process() = Process.GetProcessesByName("acrobat")
Dim myProcess As Process
For Each myProcess In myProcesses
myProcess.Kill()
Next myProcess
Timer1.Enabled = False
Form2.Show()
Me.Close()
End Sub
End Class
############################################################################
If there are any questions regarding this code, please email me on mjohl@laserf.co.za
By struggling we learn...
|
|
|
|
|
|
Hi,
I'm having an issue when adding any fields from my dataset to the report. It crashes VS2005. I can create a new report and see the datasets, however, when I drag-drop a field from my dataset to the report, it crashes immediately. Anyone run into this issue? I have included the trace. Thank you.
I have also posted a screenshot @
http://www.jennewine.com/cpdump.htm
and a log file @
http://www.jennewine.com/cpdumpText.htm
|
|
|
|
|
Hi
The article is great and resourceful. Thanks for it.I am using vs.net 2005 and reporting with ssrs 2005 bundled with it.I am programmatically binding data from Oracle 9i database through datatables. The problem is my reports are running smothly when i run them from my application (i.e from the asp.net development server) but when i precompile the website the reportviewer containing aspx page is giving the following error:
data at root level is invalid:
Please let me know what i am doing wrong Thanks again.
|
|
|
|
|
Hi All,
I want to use PDF export functionality of report viewer. But i do not want Report Viewer to display to the user.
Is it possible?
Can I customize report viewer?
Thanks in Advance
|
|
|
|
|
Hi,
Great easy to follow article.
I have the following problem though. I have 2 different tables from 2 different databases (one ORACLE and one Access) that have a one-to-one relationship. I want to be able to just join the 2 tables in a dataset with a one-to-one relationship between the 2 primary keys and then use this dataset to display the data in a table on the report.
But the Dataset designer will only allow me to create a one-to-many relationship and the Report designer insists that I have a grouping for the field that is supposedly coming from the many table.
How can I get around this?
thanks
Vicky.
|
|
|
|
|
For a one to one relationship you can do 2 adapter fills on a single datatable. If using a loosely typed dataset, then the data adapter would automatically add the additional columns if the correct schema properties are set on the SelectCommand object The primary key would need to have the same name in both databases or else you would need to do the column mapping.
If using a strongly typed dataset, then generate the datatable using one adapter and then manually add in the second table's columns ensuring that each column is nullable. Specify column mappings on the secondary select command if the primary key column name is different. When filling make sure to fill from the first database first, which will leave nulls in the secondary columns until you do the fill from the other database.
- Robert R Freeman
|
|
|
|
|
Didn't know how to do 2 adapter fills on single datatable so I have gone with the second option. Here is what I did :
Private Sub frmReportAll_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.ABN_TBLTableAdapter.Fill(Me.ds_LOPBS_ABN_rpt.ABN_TBL)
Dim dt As DataTable = Me.ds_LOPBS_ABN_rpt.ABN_TBL
Dim dr As DataRow
Dim cnn As New OracleClient.OracleConnection(gEDBPUser.EDBPConnStr)
cnn.Open()
For Each dr In dt.Rows
Dim strSQL As String = "SELECT ALLEGED_OFFENDER_FIRST_NAME, ALLEGED_OFFENDER_SURNAME FROM CM.CM_NOTIFICATION " & _
"WHERE NOTIFICATION_ID = " & dr("ABN_ID")
Dim cmd As New OracleClient.OracleCommand
cmd.CommandText = strSQL
cmd.CommandType = CommandType.Text
cmd.Connection = cnn
Dim rdr As OracleClient.OracleDataReader
rdr = cmd.ExecuteReader
rdr.Read()
dr("ALLEGED_OFFENDER_FIRST_NAME") = rdr("ALLEGED_OFFENDER_FIRST_NAME")
dr("ALLEGED_OFFENDER_SURNAME") = rdr("ALLEGED_OFFENDER_SURNAME")
rdr.Close()
rdr = Nothing
cmd = Nothing
Next
cnn.Close()
Me.rpvAll.RefreshReport()
End Sub
|
|
|
|
|
Good Example but how does one provide Page Number if the Details in the Group Span Across Multiple Pages.
The Report Will ONLY allow Paging in the Report Footer Section(Which Pirnts Pages for the Whole Report) NOT In the List Box on the Page Section!!! Is there a Formula Expression one ca use in a Textbox at the Bottom of the Group?
MAHENKE
-- modified at 10:04 Tuesday 16th January, 2007
|
|
|
|
|
Thanks for the article and code were very helpful for to get up to speed quickly using Microsoft Reporting Services (first experience). I was curious if you have much experience supplying business object classes as the datasource instead of datasets? You see, my application uses an ORM and all data objects are returned to me from my data layer in collections (IList). It appears passing the IList collection to the reporting source will work just fine, but what about passing a one-to-many data collection? Just curious if you have had any experience in this areas using the MS Reporting Services?
|
|
|
|
|
HI
I have Problem with the Microsoft Report Designer in VS2005
Cause i Want to write a custom code in my Report and Call in the report elemnts
But i cant found , my written Function . when I Call it
Please Help me , about It
Thanks and Regards
sa_tabrizi@yahoo.com
|
|
|
|
|
Hello,
I am currently working on VS 2005, and using SQL Server 2005 database. I am designing a rdlc report, in which I don't know the columns in advance, the columns can increase or decrease. So I am thinking to create a report file at runtime, and provide it data. Can anyone help me in this... It would be great if I could see some sample code as how to create file and send data through the form (Windows Form).
Thanking in advance...
Priya
|
|
|
|
|
|
This article is great...
Thanks a lot!!!
Priya
|
|
|
|
|
hi priya,
you can fetch the data from ObjectDataSource object which contains all the report data, in a DataTable.
and the you can write your own customized Report.
look at this code:
HTML SOURCE OF DEFAULT PAGE:
<rsweb:reportviewer id="ReportViewer1" runat="server" font-names="Verdana" font-size="8pt"
="" height="768px" width="1024px" onback="ReportViewer1_Back" ondatabinding="Page_Load" oninit="Page_Load" bordercolor="Black" borderstyle="Solid" skinid="1" toolbaritemborderstyle="Groove">
<localreport reportpath="D:\Pushpendra\resanddev\Report.rdlc">
Code Behind:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MyDataAdapter psk = new MyDataAdapter();
DataTable dt = new DataTable();
dt = psk.GetData();
Response.Write("");
for (int i = 0; i < dt.Rows.Count; i++)
{
Response.Write("");
for (int j = 0; j < dt.Columns.Count; j++)
Response.Write("");
Response.Write("");
}
Response.Write("" + dt.Rows[i][j].ToString() + " | ");
}
}
public class MyDataAdapter : DataSet2TableAdapters.Products_by_CategoryTableAdapter
{
public override DataSet2.Products_by_CategoryDataTable GetData()
{
return base.GetData();
}
}
<datasources>
<rsweb:reportdatasource datasourceid="ObjectDataSource1" name="DataSet1_Sales_by_Category">
<asp:objectdatasource id="ObjectDataSource2" runat="server" selectmethod="GetData"
="" typename="DataSet2TableAdapters.Products_by_CategoryTableAdapter">
PS Kaushik
|
|
|
|
|
I want to ask a general question about using report viewer of .NET 2005.
Does it require to install the visual studio 2005 on the machine in order to run an application that contains a report viewer or it can run using the .NET framework 2.0 only??
Thanks in advance
lamees
|
|
|
|
|
You do not need to install Visual Studio on the client.
The Report Viewer is a redistributable package that will be deployed with your setup project.
The Report Viewer is also available as an ASP.Net control which can be viewed with any browser.
See http://www.gotreportviewer.com/[^] for more info.
- Robert R Freeman
|
|
|
|
|
I want to know if this report can be generated dynamically ( from the runtime)
thanx in advance
lamees
|
|
|
|
|
Yes, the report file can be generated dynamically.
You can see the examples from "www.gotreportviewer.com".
|
|
|
|
|
Robert,
Thanks for the very informative tutorial. I, like many, searched for a report serices tutorial only to find very limited information.
I do have one question that I'm hoping you can answer. I have a table with a total of six columns displaying 3 fields. I have set the columns to look like this;
col1 col2 col3 col1 col2 col3
I would like to fill the table horizontally with the first record on the left, the second on the right, and the third on the left on the next line. Is this possible? If so, how can I do this.
Thanks again!
|
|
|
|
|
The only thing I can think of is to add three columns to the Datatable and then recurse through it to create the structure you want. You would need to do any sorting in the initial query.
Ex with 1 column (made to two columns):
<br />
For i As Integer = 0 To (DataSet1.DataTable1.Count - 1) / 2<br />
If i < DataSet1.DataTable1.Count - 1 Then<br />
DataSet1.DataTable1(i)(1) = DataSet1.DataTable1(i + 1)(0)<br />
DataSet1.DataTable1(i + 1).Delete()<br />
End If<br />
Next <br />
|
|
|
|
|
Hello..
First of all, good article.
You have explained master-detail grouping when only 1 table is present. That table contains all the data we are going to group (maybe one SELECT statement has joined 2 hierarchical tables), but, what if I have 2 hierarchical tables without joining them to get only 1 result set?
For example, if I have a Categories Table, and as a child, I have the Products Table. The key is CategoryId. I couldn't do what you explained here with this scenario.
Can you send me a hint how to do this?
Thanks
Jaime
|
|
|
|
|
|
Hey there,
Thanks for the article. I stumbled across it when I was trying to find out if there was anyway to get the new reportviewer control to display data in an async fashion. I have have a few reports that have literally thousands of rows of data, and for this reason, after I dynamically add the datasource (and custom dataset) to the reportviewer, I found that the reportViewer crashes(and in turn crashes my app) after the .RefreshReport() call.
Do you know of anyway to either page the data, or only display a subset of the data at a time?
Thanks
Ryan
|
|
|
|