Network Automation Software We are currently migrating this forum
over to our HelpSystems domain. Please
post all new threads in our new
HelpSystems Community Portal.
Post to the HelpSystems Forum
You are not currently logged on. You must be logged on in order to post. Log on
Or Create a new account
AutoMate Discussion
Decrease font size
Increase font size
Topic Title: Reading data from Excel and writing to a database table
Topic Summary:
Created On: 01/14/2014 03:25 PM
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
View similar topics View similar topics
View topic in raw text format. Print this topic.
 01/14/2014 03:25 PM
User is offline View Users Profile Print this message

Author Icon
JamesHalinson
Expert (100-199)

Posts: 122
Joined: 12/11/2013

Hi,

I would like to create a very simple task which reads an Excel sheet with one column of data and writes that data to a database table (single column in that table).
I have got the data into a dataset but what is the best way of writing this out to a DB? I can see the possibility of looping through line by line and writing SQL for each line but was hoping there is a more efficient way.

Thanks,

James

 01/14/2014 04:41 PM
User is offline View Users Profile Print this message

Author Icon
Valentineo McGowan
HelpSystems

Posts: 766
Joined: 09/03/2013

Hello James,

Do you already have an example of the query string you wrote to write the data within the dataset to the DB?

-------------------------

Valentineo McGowan | Technical Consultant
AutoMate | Division of HelpSystems
HelpSystems, LLC | T: +1 213.738.6966 | F: +1.213.738.7665
 01/14/2014 08:32 PM
User is offline View Users Profile Print this message

Author Icon
JeanDelfosse
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

James,
I think there is no escape but a loop.
A basic script loop on the dataset would be the most efficient way, that populates a single variable to contain many lines of
INSERT INTO 'thetable' VALUES ('thevalue');
then running a single SQL query using that variable as the query, which would insert all rows at a time into the target table.


-------------------------
Jean Delfosse - Automate Beta Tester
Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4
 01/14/2014 11:50 PM
User is offline View Users Profile Print this message

Author Icon
JamesHalinson
Expert (100-199)

Posts: 122
Joined: 12/11/2013

Thanks Jean, it's a shame there isn't some kind of bulk insert method but will look through the entities one by one.

 01/15/2014 12:33 AM
User is offline View Users Profile Print this message

Author Icon
JamesHalinson
Expert (100-199)

Posts: 122
Joined: 12/11/2013

Originally posted by: Valentineo McGowan (N.A.) Hello James, Do you already have an example of the query string you wrote to write the data within the dataset to the DB?

Hi Valentino,

I haven't yet done the part to write the data to the database but it will be something like

insert into <table> values A,B,C

Regards,

James

Statistics
18258 users are registered to the AutoMate Discussion forum.
There are currently 0 users logged in.
The most users ever online was 5551 on 01/08/2018 at 11:11 AM.
There are currently 1676 guests browsing this forum, which makes a total of 1676 users using this forum.

FuseTalk Enterprise Edition v4.0 - © 1999-2020 FuseTalk Inc. All rights reserved.

Sitemap Network Automation Software Blog