How to create StiDataSource for StiXmlDatabase ?

Stimulsoft Reports.Flex discussion
Locked
KCRomain
Posts: 23
Joined: Fri Aug 05, 2011 11:34 am
Location: Montpellier

How to create StiDataSource for StiXmlDatabase ?

Post by KCRomain »

Hi,

for my project i need to create a StiDataSource and attach them to my StiXmlDatabase. THis is the code :
var database: StiXmlDatabase = new StiXmlDatabase(DEFAULT_SET_NAME, urlXSD, urlXML);
var dataSource:StiDataSource = new StiDataTableSource(DEFAULT_SET_NAME+".ALL", "ALL", "ALL");
reportTool.dictionary.databases.add(database);
reportTool.dictionary.dataSources.add(dataSource);
reportTool.dictionary.synchronize();
I also try this :
var database: StiXmlDatabase = new StiXmlDatabase(DEFAULT_SET_NAME, urlXSD, urlXML);
var dataSource:StiDataSource = new StiDataTableSource(DEFAULT_SET_NAME+".ALL", "ALL", "ALL");
reportTool.dictionary.databases.add(database);
database.dataSources.add(dataSource);// dataSources is null at this point
reportTool.dictionary.synchronize();
And i discover adapter like this :
dataSource = database.getDataAdapter().create(DICTIONNARY ?????);
what is the right approach ?

thx, have a good day
Bérenger
Posts: 7
Joined: Tue Jul 19, 2011 8:42 am
Location: France

How to create StiDataSource for StiXmlDatabase ?

Post by Bérenger »

In fact, it's like my problem (which is not a problem) : we are not able to do in code what we do in manual mode.

1/ In Designer manual mode, we create a new dictionnary with XML+XSD urls. Our code :
var database: StiXmlDatabase = new StiXmlDatabase(, , );
reportTool.dictionary.databases.add(database);
reportTool.dictionary.synchronize();
2/ Then we create a new data source in searching the "Name in source". Our code (which doesn't work because of a null pointer exeption) :
var dataSource:StiDataSource = new StiDataTableSource(, , );
databases.dataSources.add(dataSource);
3/ Finally we want to "Retrieve columns", but we don't know how to do.



To summarize, our bit code is :
var database: StiXmlDatabase = new StiXmlDatabase("Demo", , );
var dataSource:StiDataSource = new StiDataTableSource("Demo.ALL", "ALL", "ALL");
reportTool.dictionary.databases.add(database);
databases.dataSources.add(dataSource);
reportTool.dictionary.synchronize();
The data we use are : http://dl.free.fr/g6LfZuMeE


Can you help us?
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

How to create StiDataSource for StiXmlDatabase ?

Post by Vladimir »

Hello,

The dictionary.synchronize() method builds a dictionary based on data, registered by report.regData() method. Unfortunately, at this moment it cannot be retrieved from the column from created connection to the database by using this method. We added implementation of this method to our to-do list.

Thank you.
Bérenger
Posts: 7
Joined: Tue Jul 19, 2011 8:42 am
Location: France

How to create StiDataSource for StiXmlDatabase ?

Post by Bérenger »

OK.

Is mashing code between XML data or XML url (for data source) and StiObjects (to add columns manually) works?
If yes, have you any sample of code (mostly to see which comes first and where put the synchronize method) ?
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

How to create StiDataSource for StiXmlDatabase ?

Post by Vladimir »

Hello,

You can programmatically create all the columns of the data dictionary:

Code: Select all

var column: StiDataColumn;
var dataSource: StiDataSource = new StiDataTableSource("XmlConnection.Employees", "DataSource1", "DataSource1");

column = new StiDataColumn("EmployeeID", "EmployeeID", "EmployeeID", StiSystemType.SystemInt32);
dataSource.columns.add(column);

column = new StiDataColumn("LastName", "LastName", "LastName", StiSystemType.SystemString);
dataSource.columns.add(column);

column = new StiDataColumn("BirthDate", "BirthDate", "BirthDate", StiSystemType.SystemDateTime);
dataSource.columns.add(column);
The dictionary.synhronize() method is not required.

Thank you.
Locked