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 for Programming
 Forum for Origin C
 Worksheet::WriteRecordset

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
Joe256 Posted - 01/04/2011 : 06:03:09 AM
Hello,

I am currently working with Origin 8.0951 (B951) on Windows XP, and trying to export some calculated datas from a worksheet to a database like SQL following the present example : http://www.originlab.com/www/helponline/Origin/en/programming/mergedProjects/OriginC/OCGuide/Exporting_into_a_Database.html.

#include <origin.h>
#define STR_DB_CONN "Driver={MySQL ODBC 3.51 Driver}; Server=Lintilla;Port=3306;Option=4;Database=Analysis;UID=test;PWD=test;"
#define STR_QUERY "Select * from FittingSummary"

bool write_wks_to_db()
{
Worksheet wks = Project.ActiveLayer();
if ( wks )
return false;

//connect to database "Analysis" on "Lintilla"
string strConn = STR_DB_CONN;
string strQuery = STR_QUERY;

Object oConn;
oConn = CreateObject("ADODB.Connection");
if ( !oConn )
return error_report("Fail to create ADODB.Connection object!");
oConn.Open(strConn);

Object oRecordset;
oRecordset = CreateObject("ADODB.Recordset");
if ( !oRecordset )
return error_report("Fail to create ADODB.Recordset object!");

//open recordset
oRecordset.CursorLocation = 3; //adUseClient, please refer to MSDN for details
oRecordset.Open(strQuery, oConn, 1, 3); //adOpenKeyset, adLockOptimistic

int iRowBegin = 0, nRows = 8; //8 rows
int iColBegin = 0, nCols = 9; //9 columns

//LAYWKSETRECORDSET_APPEND for appending new recordset;
//LAYWKSETRECORDSET_REPLACE for replacing existing recordsets.
int nOption = LAYWKSETRECORDSET_APPEND; //append.

int nRet = wks.WriteRecordset(oRecordset, nOption,
iRowBegin, nRows, iColBegin, nCols);
return (0 == nRet);
}


Some errors occured when compiling this piece of code.

It seems that WriteRecordset is not defined or does not have matching prototype, LAYWKSETRECORDSET_APPEND and LAYWKSETRECORDSET_REPLACE are not defined.

Is anybody think that this feature is not present within this version, do i have to do an upgrade or are there hints and tricks to accomplish such opperations ?


Could you help me please?

Thanks,

Best regards.

1   L A T E S T    R E P L I E S    (Newest First)
Penn Posted - 01/05/2011 : 03:45:07 AM
Hi,

Yes, you are right. The version you are using does not include LAYWKSETRECORDSET_APPEND yet. Please update to Origin 8 SR6 from this page and then try again.

Penn

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