The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 plot automation from tables in a database
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

rudesh

USA
Posts

Posted - 10/16/2007 :  4:06:35 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5 or 8.0
Operating System:Windows server 2003

Hi,
I want to automate the creation of a simple 2D bar graph for ~200 individual tables in a SQL database. I have had a play with the ADO interface and am able to connect to my database and download tables and plot the required figure. I'd like to be able to automate this process.
Many Thanks,

Rudesh

larry_lan

China
Posts

Posted - 10/17/2007 :  04:06:13 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Rudesh:

In Origin 8, you can use the database related functions to write an Origin C routine to auto import data and then plot graphs. Please refer to datasource.h in \OriginC\OriginLab\ folder of Origin .exe folder for database related function.

When you play with the ADO tool, you can save your query as an .ODQ file. Open this file by text editor (Windows Notepad), and then you will see the dataset connecting information. Use this information in your Origin C code. The following example will access the Origin sample database (\Samples\Import and Export\stars.mdb) and plot a scatter:


#include <Origin.h>
#include <..\originlab\datasource.c>

void test()
{
Worksheet wks=Project.ActiveLayer();

string sysPath = GetAppPath(true);

// Setting the database connecting information

string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + sysPath
+ "Samples\Import and Export\stars.mdb;Mode=Share Deny None;Extended Properties="
";Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet OLEDB:Database Password="";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Password=";

// Setting the query string

string strQuery = "Select Stars.DeclDeg, Stars.LightYears From Stars Where Stars.LightYears > 100";

if ( ! db_wks_set_query(wks, strConn, strQuery) )
{
out_str("Failed to put query information into worksheet");
return;
}

// Import data

db_wks_import(wks, 0, 0, true);

// Plot scatter

GraphPage gp;
gp.Create();
GraphLayer gl = gp.Layers();
Curve crv(wks, 0, 1);
gl.AddPlot(crv, IDM_PLOT_SCATTER);
gl.Rescale();
}


Thanks
Larry
OriginLab Technical Services

Edited by - larry_lan on 10/17/2007 04:25:08 AM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000