Origin C has the ability to export data from a worksheet to a specified database table. The following steps show how to export fitting summary data into a database.
//user should modify connect and query string according to their database settings. //such as value of Server, Database, UID, PWD etc. #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); }