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
 Import from 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

DrMK

Germany
12 Posts

Posted - 03/24/2020 :  06:55:10 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin 2019b (32-bit)
9.6.5.169
Copyright © 1991-2019 OriginLab Corporation
Windows 10

Hello,

I've got different workbooks in different Folders in my Project. For each workbook I wrote a SQL-Code for a Database-Import.

Is there any possibility to run the Import simultaneously for all workbooks with one button?

Currently I have to Import for each workbook itself.

Thank you!

Matej

YimingChen

1669 Posts

Posted - 03/24/2020 :  08:43:15 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Please check this page for script to import from database.
https://www.originlab.com/doc/LabTalk/examples/general-Import#Import_from_Included_Sample_Access_Database

To loop over each workbook, please refer to this page:
https://www.originlab.com/doc/LabTalk/ref/Document-cmd#-e_object_.7Bscript.7D.3B_Execute_the_given_script_for_all_objects

Sample script can look like this:

Doc -e W
{
string strdb$ = system.path.program$ +
                "Samples\Import and Export\stars.mdb";

string strConn$="Provider=Microsoft.Jet.OLEDB.4.0;
                Data Source=%(strdb$); User ID=; Password=;";

// The SQL
string strSQL$="SELECT Stars.Index, Stars.Name, Stars.LightYears, Stars.Magnitude
                FROM Stars
                WHERE Stars.LightYears<=100
                ORDER BY Stars.Magnitude, Stars.LightYears";

// Connect database and submit the SQL
dbEdit change conn:=strConn$ sql:=strSQL$;
// Import data
dbImport;
// Disconnect the database
dbEdit remove;
}



James
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