Page 1 of 1

weborb and/or DataTable

Posted: Tue Jan 11, 2011 7:22 am
by brianj774
Hi,

I'm evaluating this product for inclusion in ours, and I am trying to determine how to best make connection to my MSSQL data. I see that the 2010.3 version does not support connection to OleDB sources, but only XML and mysql. But, I've also seen mention by Vladimir of "For connecting data to a report, you must convert data to the XML format or to DataTable and DataSet structures, and then register data in the report."

First, could anybody point me at some resources for that conversion?

Second, is anyone here using WebOrb to transport the data, perhaps automatically doing the above-mentioned conversion?

Thanks ever so much!

weborb and/or DataTable

Posted: Tue Jan 11, 2011 9:35 am
by brianj774
I can see from the example below, that it might be possible for me to build something that would take a weborb ActiveRecord, and convert it into a dataTable/dataSet, perhaps in a re-usable way. Can anyone confirm or deny this? Does anyone have any experience in working with this idea ?
Example 2:

Code: Select all

var table: DataTable = new DataTable("Customers");
var column: DataColumn = new DataColumn("CustomerName", StorageType.StringType);
table.columns.add(column);

table.addNewRow().sett("CustomerName", "John Smith");
table.addNewRow().sett("CustomerName", "Antonio Moreno");
table.addNewRow().sett("CustomerName", "Elizabeth Brown");

var dataSet: DataSet = new DataSet("DataSetName");
dataSet.tables.add(table);

var report: StiReport = new StiReport();
report.regData("DataSetName", "DataSetName", dataSet);
report.dictionary.synchronize();
report.design();

weborb and/or DataTable

Posted: Wed Jan 12, 2011 1:00 am
by Vladimir
Hello,

Unfortunately, we do not have specific data adapters and examples for working with WebORB protocol. You need to convert data from WebORB to XML or DataSet (as you indicated above).

Thank you.

weborb and/or DataTable

Posted: Fri Jan 21, 2011 2:44 pm
by brianj774
Hello,

So, I've begun to write a data transformation function for my weborb based dataset. The big problem right off the bat, is that I'm not seeing any "DataTable", "DataSet", or "DataColumn" objects available to flex. What do I need to do to add them in ? If I just copy paste the code above, it wont even compile.

weborb and/or DataTable

Posted: Mon Jan 24, 2011 7:37 am
by Vladimir
Hello,

This is an error. We set the visibility for all necessary classes. Fix will be available in the next prerelease build on January 25.

Thank you.

weborb and/or DataTable

Posted: Thu Mar 03, 2011 7:41 am
by brianj774
For future reference, here is my function to convert a weborb queryResult (returned as an object) into a "dataTable" for comsumption by the report software:

Code: Select all


		private function dataTableGet(dataset:Array, dgItem:Object):DataTable {
			// we've been given an array of objects (returned from weborb)
			// now, convert it into a stimulsoft dataTable
			
			
			var t:DataTable = new DataTable(dgItem.String1);
			var cList:Array = dgItem.String2.toUpperCase().split(",");
				
			var c:DataColumn;
			var r:DataRow;
			var aPropList:Array;
			var item:Object;
			
			for( var i:int = 0; i < dataset.length; i++) {
				
				item = dataset[i];
				
				//Make sure we only do this part the first trip through...
				if (aPropList == null) {
					aPropList = new Array();
					
					for (var p:String in item) {
						
						// make sure that we only add the columns that we NEED, as
						// defined in the metadata
						if(ArrayUtil.arrayContainsValue(cList,p.toUpperCase())) {
							aPropList.push(p);
						}
					}
					
					aPropList.sort(); // make sure we always get the dataset columns in the same order.
					
					for (var k:int = 0; k < aPropList.length; k++) {
						// setup our columns
						var type:String =  getQualifiedClassName(item[aPropList[k]]);
						switch(type) {
							case 'int':
								c = new DataColumn(aPropList[k], StorageType.IntType);
								break;
							case 'Date':
								c = new DataColumn(aPropList[k], StorageType.DateTimeType);
								break;
							case 'Number':
								c = new DataColumn(aPropList[k], StorageType.DecimalType);
								break;
							case 'String':
								c = new DataColumn(aPropList[k], StorageType.StringType);
								break;
							default:
								c = new DataColumn(aPropList[k], StorageType.BooleanType);
								break;
						}
						t.columns.add(c);
					}
				}
				
				// the entire above if block is just a setup routine..
				// now, for each item, build the rows...
				
				r = t.addNewRow();
				
				for (var j:int = 0; j < aPropList.length; j++) {
					r.sett(aPropList[j], item[aPropList[j]]);
				}
			}
			return t;
		}
		
		

weborb and/or DataTable

Posted: Thu Mar 03, 2011 9:07 am
by Vladimir
Hello,

Thank you very much for providing solution, we will recommend it to our customers.

Have a nice day!

weborb and/or DataTable

Posted: Wed Jun 01, 2011 1:50 pm
by brianj774
An update to my 'dataTableGet' function, to deal with the fact that stimulsoft's tool doesn't work with raw date objects...my function has a dependency on a sprintf utility function, but it could be worked around easily enough without that.

Code: Select all


		private function dataTableGet(dataset:Array, reportItem:TblReport):DataTable {
			// we've been given an array of objects (returned from weborb)
			// now, convert it into a stimulsoft dataTable
			
			
			var t:DataTable = new DataTable(reportItem.SBaseView);
			var cList:Array = reportItem.SColumnList.toUpperCase().split(",");
				
			var c:DataColumn;
			var r:DataRow;
			var aPropList:Array;
			var item:Object;
			
			for( var i:int = 0; i  " + sDate);
							
							r.sett(aPropList[j], sDate);
									
							
							break;
						default:
							r.sett(aPropList[j], item[aPropList[j]]);
							
					}
					
					
					
						
				}
			}
			return t;
		}
		
		

weborb and/or DataTable

Posted: Thu Jun 02, 2011 7:39 am
by Vladimir
Hello,

In this case, you can use the following conversion:

Code: Select all

...
  case 'Date':
      r.setValue(aPropList[j], StiDateTime.fromDate(item[aPropList[j]]));
...
Also, we have made some ​​improvements, now Date object will work correctly. The update will be available in prerelease build on June, 2.

Thank you.