IRobotSoft Administrator
IRobotSoft Administrator
   

IRobotSoft, the Best Internet Robot System
Posts: 1609
Gender:
|
Attached is a quick fix for this. It allows you to use a Dataset variable to dynamically connect to a database or a table. You still need to define a data source from menu: Design -> Define Data Sources, then follow the pages to create a data source. (You may need to create a sampe table in the data source if no table is there). At the last step, when you see the data source in XML format, you copy the XML data and save it in a txt file, such as 'ds_sample.txt'. In your robot, you can load and change the 'ds_sample.txt' dynamically to connect to different databases or tables. For example, the following script code change the table name in 'ds_sample.txt' to a new name 'newtest_table' and keeps it in ds_data variable. ds_path = 'ds_sample.txt'; ds_data = readFile(ds_path); ds_data = htql(ds_data, '<Table>:Name &replace(''newtest_table'') '); Note the newtest_table should have a same schema as the origial sample table. Now we can use ds_data to load data from newtest_table like the following script: ds = Dataset(); n=ds.loadData(ds_data, 'select * from newtest_table '); Note that in the above ds.loadData function, you can run a create table or insert to any other table. Note that the DBQ is very different for different database. Please use the ODBC in Control Panel to create a file DSN and test connection to an existing table to make sure it is defined properly.
|