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 for Programming
 Forum for Origin C
 Worksheet::WriteRecordset
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Joe256

Belgium
1 Posts

Posted - 01/04/2011 :  06:03:09 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
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