|
|
Comments and Discussions
|
|
 |
|

|
I was looking for an article like this for some time now, good thing Google exists and there are people to make this kind of articles.
All the best.
http://www.reportingsoftware.info/reporting-software-standards/reporting-software-whats-the-inside-scoop/
|
|
|
|
|

|
I created a data set manually and created a datatable pricelist. The reportviewr is in a usercontrol ucReport, which is loaded inside a panel at run tyime
i have created the report i want to bound its data to by doing this
Dim oRpt As New ucReport
Dim ds As DataSet = GetDataset("prices")
Dim rds As ReportDataSource = New ReportDataSource("ReportDataSet", ds.Tables(0))
With oRpt.rvMain.LocalReport
.ReportPath = "Reports\pricelist.rdlc"
.DataSources.Clear()
.DataSources.Add(rds)
.Refresh()
End With
ths getdata source looks like
Private Function GetDataset(ByVal sName As String) As DataSet
Dim conn As New SQLiteConnection("Data Source=" & dbPath)
conn.Open()
Dim sql As String = Nothing
Select Case sName.ToLower
Case "prices"
sql = "Select * FROM prices_view"
End Select
Dim ad As SQLiteDataAdapter = New SQLiteDataAdapter(sql, conn)
Dim ds As DataSet = New DataSet
ad.Fill(ds)
Return ds
End Function
When i run the report, i don't get anything in the report viewer
|
|
|
|

|
It´s interesting for people like learn of this subject. It´s very important for the life
|
|
|
|
|

|
this is very intresting... i like this article
2. A: http://www.reportingsoftware.info/reporting-software-standards/reporting-software-whats-the-inside-scoop/
|
|
|
|

|
Hi!
Have a question:
In *.rdlc file i always have a string
<DataSetName>MyDataSetName</DataSetName>
not <DataSetName>MyDataSetName_TableName</DataSetName> as in your example.
Should i change it manualy?
Thanks!
|
|
|
|

|
Do you need better info on the products available, reporting software is a truly effective resource.
|
|
|
|

|
I found my Solution Regarding Dynamic Dataset Binding in Report Through This....Excellent..>!!
|
|
|
|

|
I want to display in reportViexer1 report.rdlc data from a xml file with VB.net if possible
thank you.
|
|
|
|

|
The RDLReportViewer[^] control is a control that shows RDL files without having SQL Server Reporting Services. The only property that you need to set on the control is the RDL file name. All the parameters will automatically be displayed[^], and all the datasets will automatically get loaded into the report. If the report needs to get changed, then simply change the rdl file and you're done. Check it out...
Chris
|
|
|
|

|
Hi It's me again sorry for the troubles
I read the rdlc as a xmldocument to get the datasets and a tables in order to use those data to create a Datasoruce.
I do this with the reportviwer.localreport.reportpath("file.rdlc") and read the rdlc as xml this a Xmldocument.read("filepath")
The problem I have is that now I want to do the same with a server report using reportviwer.serverreport.reportpath("http://localhost/file.rdlc")
To read a remote xml i use:
Dim wr As Net.HttpWebRequest = CType(Net.WebRequest.Create("http://localhost/file.rdlc"), Net.HttpWebRequest)
wr.Timeout = 10000
Dim resp As Net.WebResponse = wr.GetResponse()
Dim stream As Stream = resp.GetResponseStream()
Dim reader As XmlTextReader = New XmlTextReader(stream)
reader.XmlResolver = Nothing
ds2.ReadXml(reader)
But i get an Exception saying that "error 404 server not found", However if i change "http://localhost/file.rdlc" for "http://localhost/file.xml" i Dont get any Exception and i get the xml structure.
How could I read the rdlc file as remote xml?
Thanks a lot.
|
|
|
|

|
Hello AcidAndroid,
I don't know what kind of application are you trying to develop but, if SQL Server and IIS are involved, its better to use rdl instead of rdlc. Because, the clients will need reportviewer components installed on their computers to view rdlc reports.
Anyway, we use a system like this:
We install an SQL Server to customer's database server computer. Then we install our products on client computers of the customer. A typical server-client accounting application. We store our rdlc documents in the database server. Note that rdlc is a text file and can be base64 encoded and decoded perfectly. We store them encoded in base64. When someone wants to display a report from a client computer, we simply get the content, decode it, write to TEMP folder and use it's filepath as the reportpath. This solution may solve your problem as well.
You can use these functions to encode and decode the content.
private void someFunction()
{
string rdlc = "";
string rdlcFilePath = @"C:\Temp.....xxxx.rdlc"; rdlc = readTextFileIntoString(rdlcFilePath);
rdlc = base64Encode(rdlc);
}
public string readTextFileIntoString(string filePath)
{
string fileContents = "";
try
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(filePath);
fileContents = xDoc.InnerXml;
}
catch (Exception)
{ throw; }
return fileContents;
}
public string base64Encode(string data)
{
try
{
byte[] encData_byte = new byte[data.Length];
encData_byte = System.Text.Encoding.UTF8.GetBytes(data);
string encodedData = Convert.ToBase64String(encData_byte);
return encodedData;
}
catch (Exception e)
{
throw new Exception("Error in base64Encode" + e.Message);
}
}
public string base64Decode(string data)
{
try
{
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
byte[] todecode_byte = Convert.FromBase64String(data);
int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
char[] decoded_char = new char[charCount];
utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
string result = new String(decoded_char);
return result;
}
catch (Exception e)
{
throw new Exception("Error in base64Decode" + e.Message);
}
}
I hope it helps...
There are 10 types of people in the world. Those who understand the binary and those who don't.
|
|
|
|

|
Hi DIren,
I think it is good idea to centralize Rdlc reports inside a Sql Server database.
A small question about that :
why do you encode the xml into text ? it is not encrypted, everybody can decode. Why do not use an XML field in the sql table ?
Thanks
|
|
|
|

|
Encoding to base64 string is not for protection, but to eliminate any possible occurances of characters which may cause problems in an SQL Query, or the table itself. For ex: language specific characters. The database may not be configured to store them.
You can use an XML field, as long as you control the configuration of the database and the input XML content.
Cheers
There are 10 types of people in the world. Those who understand the binary and those who don't.
|
|
|
|

|
Hi DIren
I have done a report class based on your ideas and article but when i try to load a subreport i dont know how to pass the same dataset to subrepor i can see the data in the main rerpot but in the subreport a get a error.
here is my code and Im filling the dataset with a xml file just for test:
Dim rds As New ReportDataSource
Dim nlist As Xml.XmlNodeList
Dim d As New Xml.XmlDocument
Dim dsname As String = Nothing
Dim dstable As String = Nothing
d.Load("D:\Orders.rdlc")
ds.Reset()
ds.ReadXml("D:\SubreportInList\Orders.xml")
'I get the data for the datasource from the rdlc file
nlist = d.GetElementsByTagName("DataSet")
Me.rprtv1.LocalReport.DataSources.Clear()
For Each nodo As Xml.XmlNode In nlist
dsname = nodo.Attributes("Name").Value
For Each ele As Xml.XmlElement In nodo
If ele.Name = "rd:DataSetInfo" Then
dstable = ele.Item("rd:TableName").InnerText
Exit For
End If
Next
If dsname <> "" And dstable <> "" Then
Me.rprtv1.LocalReport.DataSources.Add(New ReportDataSource(dsname, ds.Tables(dstable)))
End If
Next
Until this i can fill the report with the proper data but how couli do it with a subrport
Thanks for your time and patience
|
|
|
|

|
There is an excellent sample in gotreportviewer.com
http://www.gotreportviewer.com/Subreport.zip
I hope it helps.
There are 10 types of people in the world. Those who understand the binary and those who don't.
|
|
|
|

|
Thanks a lot it was really helpful
|
|
|
|

|
DataRow dr;
DataTable dt = new DataTable();
dt.Columns.Add();
dt.Columns.Add();
Random rand = new Random(10000);
for (int i = 0; i < 100; i++)
{
dr = dt.NewRow();
dr[0] = i;
dr[1] = rand.Next();
dt.Rows.Add(dr);
}
DataSet ds = new DataSet();
ds.Tables.Add(dt);
ds.DataSetName = "ggg";
ds.WriteXmlSchema(@"c:\scheme");
ds.WriteXml(@"c:\scheme1");
string reportPath = @"C:\Documents and Settings\...\Report1.rdlc";//full path
Microsoft.Reporting.WinForms.ReportViewer rv = new Microsoft.Reporting.WinForms.ReportViewer();
rv.Dock = DockStyle.Fill;
this.Controls.Add(rv);
rv.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("ggg", ds.Tables[0]));
rv.LocalReport.ReportPath = reportPath;
rv.RefreshReport();
In the issue I receive an empty ReportViewer...
Help!!! May be I forget about something
|
|
|
|

|
...
ds.WriteXmlSchema(@"c:\scheme");
ds.WriteXml(@"c:\scheme1");
--------------------------------------> Your Report1.rdlc must be already designed by using the specified "scheme1.xml" data, and "scheme.xsd" scheme at this point.
string reportPath = @"C:\Documents and Settings\...\Report1.rdlc";//full path
Microsoft.Reporting.WinForms.ReportViewer rv = new Microsoft.Reporting.WinForms.ReportViewer();
...
I'm sure your problem is not related with the design. Otherwise you'd get an exception when assigning the reportpath. The code seems to be fine. I can only recommend using
ds.WriteXml(@"c:\scheme1.xml",XmlWriteMode.WriteSchema);
instead of
ds.WriteXml(@"c:\scheme1");
----
Ok. I've got it. Thats the problem:
This is your original code:
rv.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("ggg", ds.Tables[0]));
Note that "ggg" is your DataSet name. You need the name of the data source which is by default a string including both dataset and datatable names. Like this:
string dataSourceName = ds.DataSetName + "_" + dt.TableName;
So you should simply replace your data source adding line with
rv.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource(ds.DataSetName + "_" + dt.TableName , ds.Tables[0]));
Hope that helps...
Cheers
There are 10 types of people in the world. Those who understand the binary and those who don't.
|
|
|
|

|
I tried following code:
reportViewer1.ProcessingMode = ProcessingMode.Local;
reportViewer1.LocalReport.DataSources.Add(new ReportDataSource(ds.DataSetName + "_" + dt.TableName, ds.Tables[0]));
reportViewer1.LocalReport.Refresh();
But still no data is shown in report viewer. During debugging the code. reportViewer1 is showing the data, which is containing rows.
What could be the problem???
|
|
|
|

|
Hi Hari,
Your code works fine. I just renamed "reportViewer1" into "rv", and set the report path strings. I'm posting the code along with the schema and report.
DataRow dr;
DataTable dt = new DataTable();
dt.Columns.Add();
dt.Columns.Add();
Random rand = new Random(10000);
for (int i = 0; i < 100; i++)
{
dr = dt.NewRow();
dr[0] = i;
dr[1] = rand.Next();
dt.Rows.Add(dr);
}
DataSet ds = new DataSet();
ds.Tables.Add(dt);
ds.DataSetName = "ggg";
ds.WriteXmlSchema(@"c:\scheme.xsd");
ds.WriteXml(@"c:\scheme1.xml", XmlWriteMode.WriteSchema);
string reportPath = @"C:\Report1.rdlc";
Microsoft.Reporting.WinForms.ReportViewer rv = new Microsoft.Reporting.WinForms.ReportViewer();
rv.Dock = DockStyle.Fill;
this.Controls.Add(rv);
rv.ProcessingMode = ProcessingMode.Local;
rv.LocalReport.DataSources.Add(new ReportDataSource(ds.DataSetName + "_" + dt.TableName, ds.Tables[0]));
rv.LocalReport.ReportPath = reportPath;
rv.RefreshReport();
<small><?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<DataSources>
<DataSource Name="DummyDataSource">
<rd:DataSourceID>5702bc66-cacd-478e-ba6f-f2e55ec9e184</rd:DataSourceID>
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString />
</ConnectionProperties>
</DataSource>
</DataSources>
<InteractiveHeight>29.7cm</InteractiveHeight>
<rd:DrawGrid>true</rd:DrawGrid>
<InteractiveWidth>21cm</InteractiveWidth>
<rd:GridSpacing>0.25cm</rd:GridSpacing>
<rd:SnapToGrid>true</rd:SnapToGrid>
<RightMargin>2.5cm</RightMargin>
<LeftMargin>2.5cm</LeftMargin>
<BottomMargin>2.5cm</BottomMargin>
<rd:ReportID>25c74fdf-7859-4780-a4b9-cf22c56c4bb5</rd:ReportID>
<PageWidth>21cm</PageWidth>
<DataSets>
<DataSet Name="ggg_Table1">
<Fields>
<Field Name="Column1">
<DataField>Column1</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Column2">
<DataField>Column2</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
<Query>
<DataSourceName>DummyDataSource</DataSourceName>
<CommandText />
<rd:UseGenericDesigner>true</rd:UseGenericDesigner>
</Query>
<rd:DataSetInfo>
<rd:DataSetName>ggg</rd:DataSetName>
<rd:TableName>Table1</rd:TableName>
</rd:DataSetInfo>
</DataSet>
</DataSets>
<Width>16cm</Width>
<Body>
<ColumnSpacing>1cm</ColumnSpacing>
<ReportItems>
<Table Name="table1">
<DataSetName>ggg_Table1</DataSetName>
<Top>1.25cm</Top>
<Details>
<TableRows>
<TableRow>
<TableCells>
<TableCell>
<ReportItems>
<Textbox Name="Column1">
<rd:DefaultName>Column1</rd:DefaultName>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<ZIndex>1</ZIndex>
<CanGrow>true</CanGrow>
<Value>=Fields!Column1.Value</Value>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="Column2">
<rd:DefaultName>Column2</rd:DefaultName>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<CanGrow>true</CanGrow>
<Value>=Fields!Column2.Value</Value>
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
<Height>0.63492cm</Height>
</TableRow>
</TableRows>
</Details>
<Header>
<TableRows>
<TableRow>
<TableCells>
<TableCell>
<ReportItems>
<Textbox Name="textbox1">
<rd:DefaultName>textbox1</rd:DefaultName>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<ZIndex>5</ZIndex>
<CanGrow>true</CanGrow>
<Value>Column1</Value>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="textbox2">
<rd:DefaultName>textbox2</rd:DefaultName>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<ZIndex>4</ZIndex>
<CanGrow>true</CanGrow>
<Value>Column2</Value>
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
<Height>0.63492cm</Height>
</TableRow>
</TableRows>
</Header>
<TableColumns>
<TableColumn>
<Width>9cm</Width>
</TableColumn>
<TableColumn>
<Width>7cm</Width>
</TableColumn>
</TableColumns>
<Height>1.90476cm</Height>
<Footer>
<TableRows>
<TableRow>
<TableCells>
<TableCell>
<ReportItems>
<Textbox Name="textbox7">
<rd:DefaultName>textbox7</rd:DefaultName>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<ZIndex>3</ZIndex>
<CanGrow>true</CanGrow>
<Value />
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="textbox8">
<rd:DefaultName>textbox8</rd:DefaultName>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<ZIndex>2</ZIndex>
<CanGrow>true</CanGrow>
<Value />
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
<Height>0.63492cm</Height>
</TableRow>
</TableRows>
</Footer>
</Table>
</ReportItems>
<Height>5cm</Height>
</Body>
<Language>en-US</Language>
<TopMargin>2.5cm</TopMargin>
<PageHeight>29.7cm</PageHeight>
</Report></small>
br mode="hold" />
Good luck
There are 10 types of people in the world. Those who understand the binary and those who don't.
|
|
|
|

|
Thanks for the reply. I will work on it.
BTW, I like your signature.
|
|
|
|

|
Hi,
i' tried to use method shown in the previous thread but a run time i recevide this error:
Control 'ctl01_ReportViewer' of type 'UpdatePanel' must be placed inside a form tag with runat=server.
My report is inside masterpage.
|
|
|
|

|
Hi,
Great article, which has helped tremendously. I did have a problem though, which was a simple fix, if not terribly obvious.
I thought it might help anyone else out there using the same technique as me if I posted my approach. (I'm using VB, not C#, but code should be easy to follow.)
I have the ReportViewer on a winform, which also has a customer list (a Combobox) and two date fields that provide from-to values (both DateTimePickers). These supply the parameters to a web service, which calls a stored procedure with the supplied parameters and returns a dataset with the report result values.
On first running the report, this works exactly as expected.
My issue was that on re-running the report - even without changing the parameter values - the report wasn't updating to reflect the new values.
Fortunately the fix was simply calling the "Reset" of the ReportViewer before binding it.
My code goes like this:
Private Sub cmdGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGenerate.Click
Try
'Get the data matching user-specified criteria (date range/customer).
Me.LoadInvoiceReportDataset()
'Reset the ReportViewer. Required if performing subsequent report calls.
Me.rvInvoice.Reset()
'Set processing mode, report definition file, etc.
Me.SetReportProperties()
'Refresh the report content
Me.rvInvoice.RefreshReport()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub LoadInvoiceReportDataset()
Try
'Call web service to obtain report dataset.
Me.dsReport = serviceProxy.Finance_PhysioCustomer_Report_Select(CInt(Me.cbxCustomer.SelectedValue), Me.dtpFrom.Value, Me.dtpTo.Value)
''####################################################################################
''These steps are only required if the report structure changes and is intended
''for designer use only. Not required for production run-time.
''To create a representation of the report data fields, we create an XSD file
''from the dataset, then manually add it to the project so it shows up in the
''DataSources explorer.
'Me.dsReport.DataSetName = "InvRep"
''Create XML schema for the data
'Dim xw As System.Xml.XmlWriter
'xw = System.Xml.XmlWriter.Create(My.Application.Info.DirectoryPath + "\InvRep.xsd")
'Me.dsReport.WriteXmlSchema(xw)
''When running VS in debug mode, the XSD will appear in the \bin\debug folder.
''Import the new XSD as an "existing file" to the project.
''####################################################################################
Catch ex As Exception
MessageBox.Show("Error obtaining report data" & vbCrLf & ex.Message, "Error", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub SetReportProperties()
'Set properties for the report viewer.
Try
'The path to the RDLC (report layout and binding description). This is
'set to be copied locally with the app (ClickOnce required), so we can use
'the app run location as the path.
Me.rvInvoice.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local
Me.rvInvoice.LocalReport.ReportPath = My.Application.Info.DirectoryPath + "\reportInvoiceSummary.rdlc"
Me.rvInvoice.LocalReport.ExecuteReportInCurrentAppDomain( _
System.Reflection.Assembly.GetExecutingAssembly.Evidence)
'Bind the report to the viewer
Dim rdsRpt As ReportDataSource
rdsRpt = New ReportDataSource("InvRep_InvoiceReport", Me.dsReport.Tables("InvoiceReport"))
Me.rvInvoice.LocalReport.DataSources.Add(rdsRpt)
Catch ex As Exception
MessageBox.Show("Error setting Report viewer properties" & vbCrLf & ex.Message, _
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Hope that helps someone!
Alec
|
|
|
|

|
Thanks very much for your article. I would like to use the approach you outline, but I'm having a problem with filling the dataset.
I have created the XSD file and I've used ReadXMLSchema to set up the dataset definition. I understand how to bind a filled data table at runtime to the report. How do I fill the data table though? I cannot use ReadXML because my data is in SQLServer2000.
Examining the XSD file, I can see that it contains all the SQL information I need (query text, parameters etc) and I know VS can create its strongly-typed datasets based on this info. But short of directly parsing the XSD file, I don't see any methods that the DataSet class provides to create the adapter I need to fill the dataset. I tried using CreateDataReader but that doesn't work.
Can you offer any advice? I notice in your article, you seem to skip over this aspect.
|
|
|
|

|
Try searching with keywords ".NET, DataSet, SQL, Adapter".
Filling a DataSet is an elementary practice for DB application programming. Thats why it is not included.
Good luck
There are 10 types of people in the world. Those who understand the binary and those who don't.
|
|
|
|

|
Sorry, I don't mean to be thick or unclear. Of course I know how to query a database with an adapter and fill a dataset. However, in the case your article covers, we don't necessarily know the SQL query string(s) we are going to execute. The SQL query is part of the dataset definition contained in the XSD. So my question is how do I set up the adapter automatically from the DataSet definition contained in the XSD?
|
|
|
|

|
I have to use rdlc files and wanna show 3d charts can any one help me
kriskan
|
|
|
|

|
Its out of topic.
Please refer to www.rdleditor.com
There are 10 types of people in the world. Those who understand the binary and those who don't.
|
|
|
|

|
The easiest way to generate a simple RDLC from a dataset is transform the schema xml into the RDLC.
The basic idea is to build rather generic RLDC file off a DataSet. You can then bind both the DataSet and the RDLC to a ReportViewer control and get your report. I generate the RDLC by transforming the DataSet XML schema into a RDLC file via and XSLT transform.
Here is a website showing the C# code and the XSLT...
http://csharpshooter.blogspot.com/2007/08/revised-dynamic-rdlc-generation.html
|
|
|
|

|
i want make an rdlc report in which i want all object
make in run time.
simple i want make an rdlc report in which data field must
be creat in run time,
|
|
|
|

|
The rdl is an open xml format. You can find documentation on the structure of rdl. Check www.rdleditor.com
There are 10 types of people in the world. Those who understand the binary and those who don't.
|
|
|
|

|
i've tried the logic but still i'm receiving some errors here my codes : Report1.rdlc ----------> <?xml version="1.0" encoding="utf-8"?> <Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"> <BottomMargin>1in</BottomMargin> <RightMargin>1in</RightMargin> <rd:DrawGrid>true</rd:DrawGrid> <InteractiveWidth>8.5in</InteractiveWidth> <rd:SnapToGrid>true</rd:SnapToGrid> <Body> <ReportItems> <List Name="list1"> <Left>0.5in</Left> <ReportItems> <Textbox Name="textbox1"> <rd:DefaultName>textbox1</rd:DefaultName> <Width>1.5in</Width> <Style> <PaddingLeft>2pt</PaddingLeft> <PaddingBottom>2pt</PaddingBottom> <PaddingRight>2pt</PaddingRight> <PaddingTop>2pt</PaddingTop> </Style> <CanGrow>true</CanGrow> <Height>0.25in</Height> <Value>=Fields!pcode.Value</Value> </Textbox> </ReportItems> <DataSetName>DataSet1_DataTable1</DataSetName> <Top>0.25in</Top> <Width>3.5in</Width> <Height>1in</Height> </List> </ReportItems> <Height>2in</Height> </Body> <rd:ReportID>2ec40e93-afa1-4fc5-8ff3-a2fb87b83521</rd:ReportID> <LeftMargin>1in</LeftMargin> <Width>6.5in</Width> <InteractiveHeight>11in</InteractiveHeight> <Language>en-US</Language> <TopMargin>1in</TopMargin> </Report> ------------------------------------------ my C# codes-------------------------------> private void LoadDataToReport() { string connectionString = "Data Source=localhost;" + "Initial Catalog=ibidentrial;User=root"; string SQL = "SELECT * FROM emp"; MySqlConnection con = new MySqlConnection(connectionString); MySqlCommand com = new MySqlCommand(SQL, con); MySqlDataAdapter adapter = new MySqlDataAdapter(com); DataSet ds = new DataSet(); try { con.Open(); adapter.FillSchema(ds, SchemaType.Mapped, "DataTable1"); adapter.Fill(ds, "DataTable1"); } catch (Exception err) { Console.WriteLine(err.ToString()); } finally { con.Close(); } ds.DataSetName = "DataSet1"; ds.WriteXmlSchema("c:\\testing1.xsd"); ds.WriteXml("c:\\testing1.xml"); ds.ReadXmlSchema("c:\\testing1.xsd"); ds.ReadXml("c:\\testing1.xml");
reportViewer1.ProcessingMode = ProcessingMode.Local; reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1_DataTable1", ds.Tables[0])); reportViewer1.LocalReport.ReportPath = "C:\\Report1.rdlc"; reportViewer1.RefreshReport();
} error receive : The list 'list1' is in the report body but the report has no dataset. Data Regions are not allowed in reports without datasets. what seems to be the problem of my codes?did i miss something or what?..... please help i need it very badly............... im just using c# express edition and i used the vwd express edition to design the Report.rdlc ........ tnx
-- modified at 7:49 Tuesday 26th June, 2007
|
|
|
|

|
Hello,
The dataset I'm using gets fed its data after applying a pivot to the data returned from a SQL query (i.e. The rows returned in the query become the columns in the report) As a result, I don't know how many columns will be in the report until runtime, so I need to generate both my RDLC and dataset at runtime. I can create a sample dataset to generate a schema, but it will likely have the wrong number of columns when it comes to the final report.
Do you have any idea how to handle this situation?
The column names and data are bound to a field in the dataset. The problem I'm seeing is in the changing quantity of columns.
Thank you for any help you can provide.
Tony Barton.
|
|
|
|

|
Have you checked the report item "matrix" ? I know it can be used in dynamically changing columns. If it doesn't help, you can always create an rdlc file programatically in runtime. But it is a very costly approach. I recommend you try to solve your problem with Matrix control.
There are 10 types of people in the world. Those who understand the binary and those who don't.
|
|
|
|

|
I want to Generate rdlc & rdlc data source from by object collection at runtime. How can I do that?
|
|
|
|

|
We discussed this issue with my collegues in MKOM. There are a couple of pissible solutions, using collection class methods, etc. But we reached a consensus on the best way to do this is to create an object collection to dataset converter. Then use the converter to convert your object list to a dataset. Once dataset is formed, rest is piece of cake.
Good Luck
There are 10 types of people in the world. Those who understand the binary and those who don't.
|
|
|
|

|
Hey.
Ok, I'v got the report and I can see that.
Is there any way to save the reportView to the file?
I would like to save it to the Word (DOC) file, but failed to find the way to do that.
Is it possible?
Best regards,
Michael Gershkovich
|
|
|
|

|
Yes, it is possible. There is no perfect solution offered built-in currently, but there are some 3rd party tools to do that. You should either try and find a tool or code it yourself.
Currently, you can export excel and pdf files directly. There are lots of limitations tough. Check MSDN forums and gotreportviewer. Links are in www.rdleditor.com
There are 10 types of people in the world. Those who understand the binary and those who don't.
|
|
|
|

|
Hi DIren,
I am according the step you are list in the article, but i am facing a problem. That is i don't know what the mean by "Load the schema" and how to do it. Can you list in details how to generate report at runtime or direct me to any tutorial or any related sources?
thanks in advance
cocoonwls
|
|
|
|

|
Well, I don't know any "Load the Schema" step either. But let me try to simplify it a little bit more;
You need a schema in order to tell the report, from which field to get the data. You can do this by manually creating a schema which is basicly an xml document. Or, (if you are able to create a sample dataset, a data stub) create the dataset and populate data in the dataset in a method, then take schema of the dataset.
For example, you know, you'll need 3 data fields for a tabular report. These are "ID", "Name", "Surname". You can either manually create a schema representing this data structure, or do it programmatically. This is a tutorial from w3schools : http://www.w3schools.com/schema/default.asp[^]
Or, you can, create the dataSet, populate the data from whereever you want. (An SQL query may be; "SELECT * FROM PERSONNEL") use dataSet.WriteXmlSchema()
These are all in the article. I don't know what else I can write.
I hope it helped.
Cheers
There are 10 types of people in the world. Those who understand the binary and those who don't.
|
|
|
|

|
Hi DIren,
Thanks for your help,I will try it again
Best Regards
cocoonwls
|
|
|
|

|
This is no doubt one of the most useful articles on codeproject. I used to do the same thing using crystal reports a few years back but had problems with the MS reportviewer version because i was completely new to it. This solved most of my problems. Would u believe it took me almost a day to get it working! Alls well that ends well. Thanks Man!
|
|
|
|

|
Thank you harindaka. I'm glad you found it useful. As I've wrote in the article, this problem gave me the worst headaches.
Good luck on what you are doing.
Cheers...
DIren
There are 10 types of people in the world. Those who understand the binary and those who don't.
|
|
|
|

|
Hi,
I am working on reports in vs 2005.
I am using charts,reports are coming but all graph lines are in equal highet.
madhuri
|
|
|
|

|
I'm sorry man,
you just have to search for your answer elsewhere... Take a look at links that I've provided in earlier messages.
Good luck.
There are 10 types of people in the world. Those who understand the binary and those who don't.
|
|
|
|

|
I am a newbie in Reporting Services. I am trying to load rdlc programmatically combine with xml and xsd files. I used 2 interfaces. first, with Tabcontrols (just click a bottom and a report viewer will load my reports on another tab) and the second with open a new form.
with new form, I can generate and load a report in a few seconds. but, it doesn't work with tabcontrols, it takes a long time to load it.
////////////////////////////////////////////////
Here is the list part from new form interface
private void button9_Click(object sender, EventArgs e)
{
bool ret = getReportDataSet(ref dsReport, dataSetName, dataTableName);
string reportSourceFile = getProjectSourcePath() + @"\Retail System.rdlc";
frmReportView f = new frmReportView();
f.repView.Reset();
f.FormCaption = "Test Reports";
f.ReportDisplayName = "Reports";
f.repView.LocalReport.ReportPath = reportSourceFile;
ReportDataSource reportDataSource = new ReportDataSource(dataSetName + "_" + dataTableName, dsReport.Tables[0]);
f.repView.LocalReport.DataSources.Add(reportDataSource);
f.repView.RefreshReport();
f.Show();
}
private void frmReportView_Load(object sender, EventArgs e)
{
this.Text = this.FormCaption;
LocalReport l = repView.LocalReport;
l.DisplayName = this.ReportDisplayName;
//this.repView.ShowToolBar = false;
this.repView.DocumentMapCollapsed = true;
totalPages = this.repView.LocalReport.GetTotalPages();
reportPageSettings = repView.LocalReport.GetDefaultPageSettings();
pageSetupDialog = new PageSetupDialog();
pageSetupDialog.PrinterSettings = new PrinterSettings();
pageSettings = new PageSettings(pageSetupDialog.PrinterSettings);
pageSetupDialog.PageSettings = new PageSettings();
pageSetupDialog.PageSettings = pageSettings;
pageSetupDialog.PageSettings.Margins = repView.LocalReport.GetDefaultPageSettings().Margins;
pageSetupDialog.PageSettings.PaperSize = repView.LocalReport.GetDefaultPageSettings().PaperSize;
this.repView.RefreshReport();
}
And here is for tabcontrols interface
/////////////////////////////////////////
private void button5_Click(object sender, EventArgs e)
{
bool ret = getReportDataSet(ref dsReport, dataSetName, dataTableName);
string reportSourceFile = getProjectSourcePath() + @"\Report1.rdlc";
repView.Reset();
FormCaption = "Test Report";
ReportDisplayName = "Test";
repView.ProcessingMode = ProcessingMode.Local;
repView.LocalReport.ReportPath = reportSourceFile;
ReportDataSource reportDataSource = new ReportDataSource(dataSetName + "_" + dataTableName, dsReport.Tables[0]);
repView.LocalReport.DataSources.Add(reportDataSource);
repView.RefreshReport();
this.LoadReport();
this.repView.Show();
MessageBox.Show("Done", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private bool LoadReport()
{
this.Text = this.FormCaption;
LocalReport l = repView.LocalReport;
l.DisplayName = this.ReportDisplayName;
//this.repView.ShowToolBar = false;
this.repView.DocumentMapCollapsed = true;
totalPages = this.repView.LocalReport.GetTotalPages();
reportPageSettings = repView.LocalReport.GetDefaultPageSettings();
pageSetupDialog = new PageSetupDialog();
pageSetupDialog.PrinterSettings = new PrinterSettings();
pageSettings = new PageSettings(pageSetupDialog.PrinterSettings);
pageSetupDialog.PageSettings = new PageSettings();
pageSetupDialog.PageSettings = pageSettings;
pageSetupDialog.PageSettings.Margins = repView.LocalReport.GetDefaultPageSettings().Margins;
pageSetupDialog.PageSettings.PaperSize = repView.LocalReport.GetDefaultPageSettings().PaperSize;
this.repView.RefreshReport();
return true;
}
Could you help me to solve this problem ??
thx
|
|
|
|

|
Hi Arek,
You are seeking answers in a wrong place. This article has nothing to do with the user interface. Let me point you to the right direction.
www.rdleditor.com is a bookmark website. There are 2 MSDN forum links that you can access from this site. Its a better idea to ask them. And if you find an answer, may be you would write an article to codeproject ?
Good luck buddy.
There are 10 types of people in the world. Those who understand the binary and those who don't.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
Binding DataSet and Generic *.rdlc Reports to a ReportViewer at runtime
| Type | Article |
| Licence | CPOL |
| First Posted | 28 Mar 2006 |
| Views | 373,288 |
| Bookmarked | 102 times |
|
|