Using data set as Source...Ideas/Problems.

Stimulsoft Reports.NET discussion
Post Reply
fkmfkm
Posts: 181
Joined: Thu Jul 05, 2007 11:26 pm
Location: Kuala Lumpur

Using data set as Source...Ideas/Problems.

Post by fkmfkm »

I want to design my dataset using VS2005 dataset (XSD file). I will create my report source from this XSD file. I will then use the Vs adapter or some custom adapter/routine to populate this a table then bind to the report.

Is this a good idea ?

I notice a problem here..in the report designer. In the Connection Property the PathSchema is hardcoded here...The problem is its not tied to VS project. Lets say another programmer need to refresh it..he got to reselect the file...Am I doing something wrong here ?

Please help.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Using data set as Source...Ideas/Problems.

Post by Edward »

Such a solution is possible.

You define the DataSet in code and then you register it in the report's Dictionary and may even full rebuild the Dictionary. The DataSet may be build and filled from the file in your project via ReadXMLSchema() and ReadXML() methods of the DataSet accordingly. It is not necessary to define a XML Connection in dictionary and specify path for it in the Deigner in that case. The XMLConnection may be registered in the report's Dictionary in runtime manually.

The code for rebuilding the Dictionary may be the following:

Code: Select all

report.Dictionary.Clear();
report.RegData("DataSetName", dataSet);
report.Dictionary.Synchronize()
Thank you.
fkmfkm
Posts: 181
Joined: Thu Jul 05, 2007 11:26 pm
Location: Kuala Lumpur

Using data set as Source...Ideas/Problems.

Post by fkmfkm »

I think you read me abit wrongly (or I read you wrongly ?)

I am using the designer in VS to create the dataset in XSD format. Then I will design my StiWebReport(in my aspx page). I have to manually select this physical XSD in the stimul designer.

I am not doing it using any coding ..
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Using data set as Source...Ideas/Problems.

Post by Edward »

fkmfkm wrote:The problem is its not tied to VS project. Lets say another programmer need to refresh it..he got to reselect the file...Am I doing something wrong here ?
So may be an existing xsd file (and /or xml file too) be replaced later by other programmer?

If the xsd schema is not tied with the project, so you need to register it in report's Dictionary, isn't it? There are exists two ways to do this.
1. Set a XML connection inside the report template and specify the path to the xsd file with schema and path to xml file with data for report. This is not suitable as I understood.
2. Also the data may be add to the dictionary by code, when you pass to the report's dictionary ready DataSet via report.RegData("DataSetName", dataSet); And this dataSet may be created in other module from those xsd and xml files (by another programmer).

fkmfkm wrote:Then I will design my StiWebReport(in my aspx page). I have to manually select this physical XSD in the stimul designer.

I am not doing it using any coding ..
But I think you should to do this. May be I haven't understood your goal...

Please tell me the result you want to achieve in more details.
fkmfkm
Posts: 181
Joined: Thu Jul 05, 2007 11:26 pm
Location: Kuala Lumpur

Using data set as Source...Ideas/Problems.

Post by fkmfkm »

If the XSD file is within the project how to I reference it from my STIReportWeb ? I can't manage to reference it.

My idea is to design the source myself. Cause I dont want to depends on the structure of the DB...its too rigid this way...what is your suggestion ?
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Using data set as Source...Ideas/Problems.

Post by Edward »

fkmfkm wrote:If the XSD file is within the project how to I reference it from my STIReportWeb ? I can't manage to reference it.
The XMLConnection may be established directly in the designer when you have to specify a path to xsd file explicitly. This way is very convenient while designing a report. Aftter designing a report this Connection may be deleted from the dictionary manually also all DataSources may be deleted after designing.
So you may have 2 cases:
1. Fully empty Dictionary
2. All DataSources are presented but the Connection is not defined.

1. Please use the following code in that case:

Code: Select all

StiReport report = StiReportWeb.GetReport();
DataSet myDataSet = new DataSet();
myDataSet.ReadXmlSchema("myfileinProject.xsd");
// or any other way to get data in it.
myDataSet.ReadXML("myData");
report.RegData("NameOfConnection",myDataSet);
report.Dictionary.Synchronize();
StiWebViewer.Report = report;
2. When you register a dataset with the name of the deleted XML connection, then all datasources in it will be connected to that DataSet from your code. This DataSet (in your code) you may create manually from existing in project xsd file.

Code: Select all

StiReport report = StiReportWeb.GetReport();
DataSet myDataSet = new DataSet();
myDataSet.ReadXmlSchema("myfileinProject.xsd");
// or any other way to get data in it.
myDataSet.ReadXML("myData");
report.RegData("NameOfConnection",myDataSet);
StiWebViewer.Report = report;
fkmfkm wrote:My idea is to design the source myself. Cause I dont want to depends on the structure of the DB...its too rigid this way...what is your suggestion ?
The suggestion is following:
1. Create an xsd with all tables which may be available.
2. Design a report with this xsd schema and specify XML connection with path to this file. After designing when the report template is ready, you mayfully clear the Dictionary and use the first way of code above.


Thank you.
fkmfkm
Posts: 181
Joined: Thu Jul 05, 2007 11:26 pm
Location: Kuala Lumpur

Using data set as Source...Ideas/Problems.

Post by fkmfkm »

Edward,

Actually I do not understand why do you need to delete the datasource after you have designed the report. Wouldn't it be easier if you leave the datasource there ? Cause I used to do that in Crystal Report. I just need to referesh the datasource after after i made changes to the XSD.

Wouldn't that be easier ?

Need your comment/suggestion.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Using data set as Source...Ideas/Problems.

Post by Edward »

It is not necessary to delete all DataSources from the Dictionary. If you need simply add some new columns/DataSources to the Dictionary then please use

report.Dictionary.Synchronize()

method which allows you to add DataSources or(and) Columns to existing Dictionary. But in that case please note that your new xsd shema will contain all tables and Columns which are used in the relations between not presented Columns. In other case you will receive an error that such a relation can not be created in DataSource when one of Column doesn't exists.

So if the xsd will be only enlarged and filled with new Columns/DataSources, so you really do not need to clear the Dictionary, you are absolutely correct.

Thank you.
Post Reply