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
 LabTalk Forum
 Exporting worksheet into online 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
achu6393 Posted - 06/16/2017 : 04:07:35 AM
Hello all!

I am working with a lot of excel files and it is tedious to work with them seperately. Is there a possible way that these excel sheet can be combined together in origin (as a excel sheet or worksheet) which can then be uploaded into a MySQL database online.


Origin Ver. and Service Release (Select Help-->About Origin): 2016Pro 9.3
Operating System: Win 7

such coding! much wow!
8   L A T E S T    R E P L I E S    (Newest First)
aplotnikov Posted - 07/03/2017 : 06:56:42 AM
Hello Achu,

You have to change strings strConn & strQuery in accordance with the configuration of your SQL-server.
You can find some more information in the file ADOSample.c (you can find it in the directory <Originb installation directory>\Samples\COM Server and Client\ADO\Client\)

Regards,

Alexei

P.S. I would suggest to discuss problems relevant to OriginC in the correspoding forum.
achu6393 Posted - 06/30/2017 : 05:53:59 AM
UPDATE..

I made a few changes to the code to test where the error is from:

int	write_wks_to_db(){
	Worksheet wks = Project.ActiveLayer();
	if ( !wks )
		return 5;
	
	//connect to database "Analysis" on "Lintilla"
	string	strConn = STR_DB_CONN;
	string	strQuery = STR_QUERY;
	
	Object	oConn;
	oConn = CreateObject("ADODB.Connection");
	if ( !oConn )
		return 4;
	oConn.Open(strConn);
	
	Object	oRecordset;
	oRecordset = CreateObject("ADODB.Recordset");
	if ( !oRecordset )
		return 3;
	
	//open recordset
	oRecordset.CursorLocation = 3; //adUseClient, please refer to MSDN for details
	oRecordset.Open(strQuery, oConn, 1, 3); //adOpenKeyset, adLockOptimistic

	int iRowBegin = 0, nRows = 4; //8 rows
	int iColBegin = 0, nCols = 8; //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);
}


And get the following error message when i run it.
quote:
Multiple-step operation generated errors. Check each status value.


How can I solve this?


such coding! much wow!
achu6393 Posted - 06/28/2017 : 12:33:21 PM
Hello Alexie,

Personally, since i am more familiar with origin and Labtalk than excel i used origin to append all the files together. However, I am having trouble uploading the worksheet to the database.

I tried the code from the shared link however it doesnt seem to be working. I do not get any error messages neither is the data from the worksheet is uploading.

Is it not possible with Labtalk to upload worksheets to an online database?

Thank you.
Achu.

such coding! much wow!
aplotnikov Posted - 06/20/2017 : 03:44:07 AM
Hello Achu,

yes, it is. It can be done for .csv files as well, but the format in this particular case does not matter.

If you have no Excel and you will certainly implement export procedure in Origin, you can use OriginC to access ADO object: http://www.originlab.com/doc/OriginC/guide/Exporting-into-a-Database.

Regards,

Alexei
achu6393 Posted - 06/19/2017 : 04:02:21 AM
Hello Alexie,

Can this be done for csv files also?

Thanks!
Achu

such coding! much wow!
aplotnikov Posted - 06/16/2017 : 08:49:39 AM
Hello Achu,

I would suggest to combine your Excel files in Excel and then export data into SQL database. You can even avoid combining step by exporting data from each file directly - just do it in a loop over your files. Afterwards you can easily import data from your database in Origin for further processing.

You can do it in Origin as well using COM interface to ADO objects in OriginC. But I'm not sure that it will be faster and simplier than in Excel.

Regards,

Alexei
achu6393 Posted - 06/16/2017 : 08:22:09 AM
Hello Alexei,

I have a folder of excel files which I want to combine into a single worksheet in Origin. Also not all of the data recorded in the excel sheet are used but only from specific froup of cells from each sheet.

That is why I thought it would be easier to use origin. or do you think I am making things more complicated?

Cheers!
Achu


such coding! much wow!
aplotnikov Posted - 06/16/2017 : 06:17:52 AM
Hi achu6393,

I am just curious what is the reason to combine Excel files in Origin if you can do it easily using Excel itself? You can use Excel for database export as well.

I use routinely OriginC COM interface to access ADO object to export data from Origin projects to SQL database, however it seems a bit sophisticated to use Origin for the manipulations on Excel files.

Regards,

Alexei

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