Page 1 of 1

How to create StiDataSource for StiXmlDatabase ?

Posted: Mon Aug 08, 2011 2:32 am
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

How to create StiDataSource for StiXmlDatabase ?

Posted: Mon Aug 08, 2011 3:53 am
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?

How to create StiDataSource for StiXmlDatabase ?

Posted: Mon Aug 08, 2011 8:09 am
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.

How to create StiDataSource for StiXmlDatabase ?

Posted: Mon Aug 08, 2011 8:56 am
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) ?

How to create StiDataSource for StiXmlDatabase ?

Posted: Tue Aug 09, 2011 2:01 am
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.