Author |
Topic |
|
Joe256
Belgium
1 Posts |
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.
|
|
Penn
China
644 Posts |
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 |
|
|
|
Topic |
|
|
|