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
 LabTalk Forum
 Exporting worksheet into online database
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

achu6393

India
38 Posts

Posted - 06/16/2017 :  04:07:35 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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!

aplotnikov

Germany
162 Posts

Posted - 06/16/2017 :  06:17:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Edited by - aplotnikov on 06/16/2017 06:28:01 AM
Go to Top of Page

achu6393

India
38 Posts

Posted - 06/16/2017 :  08:22:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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!
Go to Top of Page

aplotnikov

Germany
162 Posts

Posted - 06/16/2017 :  08:49:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

achu6393

India
38 Posts

Posted - 06/19/2017 :  04:02:21 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello Alexie,

Can this be done for csv files also?

Thanks!
Achu

such coding! much wow!
Go to Top of Page

aplotnikov

Germany
162 Posts

Posted - 06/20/2017 :  03:44:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

achu6393

India
38 Posts

Posted - 06/28/2017 :  12:33:21 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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!
Go to Top of Page

achu6393

India
38 Posts

Posted - 06/30/2017 :  05:53:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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!
Go to Top of Page

aplotnikov

Germany
162 Posts

Posted - 07/03/2017 :  06:56:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
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