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
 All Forums
 Origin Forum
 Origin Forum
 plot automation from tables in a database

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
rudesh Posted - 10/16/2007 : 4:06:35 PM
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
1   L A T E S T    R E P L I E S    (Newest First)
larry_lan Posted - 10/17/2007 : 04:06:13 AM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000