Welcome, Guest. Please Login.
IRobotSoft Robot
09/30/23 at 08:31:41
News: Welcome to the IRoboSoft Visual Web Scraping and Web Automation forum.
Home Help Search Login
Google
 


Pages: 1
Send Topic Print
ODBC Data Source Question (Read 8161 times)
s_t_eggers
Junior Member
**


I Love IRobotSoft

Posts: 15
Gender: male
ODBC Data Source Question
06/10/15 at 00:41:41
 
Hello,
 
I've figured out how to connect IRobot to an MS SQL Server Database so long as I'm connecting to an existing database.  My question is this:  once I've gotten IRobot to make the connection and then get to the screen with the XML code, can I modify the XML with new data (such as a new name for the database and any other fields I wish to modify), causing IRobot to create new databases on the fly?
 
Or will IRobot only connect to pre-existing databases?
 
Best Regards,
 
Stephen
Back to top
 
 

My kids think I'm Superman. But I'm not fooled. Soon they'll be teenagers. Then I won't even rate high enough to be a sidekick!
  IP Logged
IRobotSoft Administrator
IRobotSoft Administrator
*****


IRobotSoft, the Best
Internet Robot
System

Posts: 1609
Gender: male
Re: ODBC Data Source Question
Reply #1 - 06/11/15 at 18:08:45
 
Currently it only supports predefined data sources.  But this is a good suggestion, we will try to make a new version with support for it soon.  
 
Back to top
 
 

The Administrator.
WWW   IP Logged
s_t_eggers
Junior Member
**


I Love IRobotSoft

Posts: 15
Gender: male
Re: ODBC Data Source Question
Reply #2 - 06/11/15 at 22:37:04
 
So if I understand your response, I have to first create the database I want to use in MS SQL Server, then tell IRobot to find it and use it.  Is this correct?
 
If it is, how do I tell IRobot to find the specific database I want it to use?  Is this what I'm supposed to put in the "DBQ" field?  I'm curious, what does "DBQ" stand for anyway?
 
Thank you for your help!
 
Best Regards,
 
Stephen
Back to top
 
 

My kids think I'm Superman. But I'm not fooled. Soon they'll be teenagers. Then I won't even rate high enough to be a sidekick!
  IP Logged
IRobotSoft Administrator
IRobotSoft Administrator
*****


IRobotSoft, the Best
Internet Robot
System

Posts: 1609
Gender: male
Re: ODBC Data Source Question
Reply #3 - 06/12/15 at 01:28:49
 
Yes, currently you will need to create and define the data source before you can use it in IRobot.  The DBQ is usually the database location, or the instance name.  If you are not sure, you can use the Windows ODBC configuration tool to save a .dsn file, and load it from the .dsn file.  
 
Back to top
 
 

The Administrator.
WWW   IP Logged
s_t_eggers
Junior Member
**


I Love IRobotSoft

Posts: 15
Gender: male
Re: ODBC Data Source Question
Reply #4 - 06/12/15 at 18:21:36
 
Okay.  So if I put the location of the database that I want IRobot to connect to into the DBQ field, is IRobot supposed to connect to that database?  I ask because no matter what I put into the DBQ field, IRobot connects to the first database it finds, which is a system database.
 
I have tried to get IRobot to connect to other databases by entering their locations, but it will only connect to the same system database.  Am I missing something?
 
Best Regards,
 
Stephen
Back to top
 
 

My kids think I'm Superman. But I'm not fooled. Soon they'll be teenagers. Then I won't even rate high enough to be a sidekick!
  IP Logged
IRobotSoft Administrator
IRobotSoft Administrator
*****


IRobotSoft, the Best
Internet Robot
System

Posts: 1609
Gender: male
Re: ODBC Data Source Question
Reply #5 - 06/13/15 at 00:07:04
 
Which method are you using to connect databases?  Are you using the loadData function, the saveVariable page to save to database, or the form inputs page to read from database?  
 
Back to top
 
 

The Administrator.
WWW   IP Logged
IRobotSoft Administrator
IRobotSoft Administrator
*****


IRobotSoft, the Best
Internet Robot
System

Posts: 1609
Gender: male
Re: ODBC Data Source Question
Reply #6 - 06/13/15 at 01:30:38
 
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.  
 
 
Back to top
 

The Administrator.
WWW   IP Logged
s_t_eggers
Junior Member
**


I Love IRobotSoft

Posts: 15
Gender: male
Re: ODBC Data Source Question
Reply #7 - 06/16/15 at 18:44:57
 
Okay, I finally took another look at the ODBC file DSN creation form in Windows.  I had overlooked the part where you name the database you want the file DSN to connect to.  Because I hadn't defined one the first time I created a file DSN, IRobot was trying to connect to the first one it found.
 
I created a new file DSN, indicating a different database.  Upon using it, IRobot was able to find the database I wanted to use.  
 
As for the latest version of IRobot attached to this thread, are you saying that so long as I create a database with a sample table in it, IRobot can create new tables on the fly (just like the sample table)?  Can I create as many tables as I wish in the same database?
 
And where does the script go?  I'm still fairly new to IRobot, so I appreciate the continued help.
 
Best Regards,
 
Stephen
Back to top
 
 

My kids think I'm Superman. But I'm not fooled. Soon they'll be teenagers. Then I won't even rate high enough to be a sidekick!
  IP Logged
IRobotSoft Administrator
IRobotSoft Administrator
*****


IRobotSoft, the Best
Internet Robot
System

Posts: 1609
Gender: male
Re: ODBC Data Source Question
Reply #8 - 06/16/15 at 19:45:10
 
Yes, with the new version, you can create as many tables as you like.  Note you still need to run a regular "create table ..." statement through the ds.loadData() function to create a new table.   Then you need to modify the schema on the fly to query the new table.  
 
You can put a script in an Event value, where you usually put expression, then choose the ValueType as Script.  
 
Back to top
 
 

The Administrator.
WWW   IP Logged
Pages: 1
Send Topic Print