Skip to main content

Good morning

I have a question and just wanted to get your point of view, or any othe idea I may apply in my task.

 

I have a bot which have 231 lines

With the Try, Catch and Finally actions

 

At the very beginning (line 11) I have a database connection, and the next line in a query

 

 

The bot runs perfectly and I control another errors depending on the error description DO this or DO this other thing.

 

But once in a while I have a problem of connection to the database, then all the process fail.

 

My idea is transfer all the data from the database to an excel file, then when the error description is like “The provided connection details are invalid” or the adequate error message  the task should get the info (fields) from the excel file and continue working as expected.

 

I fail with my idea.

                               If errordescription like “bla bla bla” then

Get the data from excel

 

 

Should I copy here from the line 22 until the end to get the full task executed??? Or how I could continue ?

 

Also have the idea of:

Error description is “xxxxx” Run tis other task, wich would be a copy from the original but getting the data from excel… and then closse both tasks

 

I do not know which could be the best option.

 

Thks for your thoughts and ideas.

Jose Marin

Hi @Jose Marin,

 

Are you copying the data from database to excel or excel to database?

As per your error details, you are getting the error at line 11 Database: Connect right? you want to ignore that and proceed but without proper connection to database how will you complete the process. First you need to make sure connection is established to DB or not. 

The steps you are doing as per screenshot:

  1. Connect to DB
  2. Fetch data
  3. In loop: creating folders and then copying data to excel?

Could you please elaborate more.

 

Thanks,

Hemantha Pindra


Hi,

@HemanthaPindra

In BLUE you have my reply.

Are you copying the data from database to excel or excel to database?

I am copying the data from database to excel once a day (every day replacing the file ,just in case any modification)

 

As per your error details, you are getting the error at line 11 Database: Connect right?

yes, when the connection is lost I am getting “The provided connection details are invalid” 

you want to ignore that and proceed but without proper connection to database

This would be the possible solution, ignore the error and then read the data from the excel file, contrary I can not continue.

how will you complete the process.

My idea was to call another different task identical to the existing one but reading the data from the excel instead of database as I have not connection to the database.

 

First you need to make sure connection is established to DB or not. 

Yes, for sure, the main issue is getting connected to the database contrary I can not continue….. but if I can not continue with the database, then change the database to an excel file.

 

The steps you are doing as per screenshot:

  1. Connect to DB
  2. Fetch data
  3. In loop: creating folders and carrying another procedures according to the data got.

 

Thanks,

Jose Marin


Error Handling can do something like that, with the Connect action in the Try, the Catch would capture the line number (number variable) and the error description. Then in the catch you can have the condition to check if it meets your criteria. You’d want to properly close out of the task, closing any existing files and connections, to ensure the desktop is clear before try to do the Run Task. That would transfer control to the new task (getting data from a spreadsheet) you’d want to check how that task returns data, as after the backup process completes the control returns to the Run Task and finishes the bot from there.

My question is, can you determine the reason for the failed database connection?

What type of database are you connecting to? Excel as a DB?

If spreadsheet is more reliable, why attempt the database connection?


 

I have an idea like below.

Try

Try

assign flag = true

connect DB

Catch

if error does not null then

assign flag = false

 

if flag = true (DB connection success)

query to get data in DB session

export query data to data table variable

 

if flag = false (DB connection failure due to xxx reason)

open excel advanced 

get multiple cells to get data into data table variable

 

(now data table variable either contain DB data or Excel data)

you can do loop of data table variable to do some validation and set into to excel file

Catch

Finally 

if flag = true

disconnect DB

if flag = false

disconnect excel

 


Good morning,

Jon, this one of my ideas, this solution could be the best …

On the other hand, yes, I can determine the reason, the msg is “The provided connection details are invalid”, the databse is as SQL database,  using the database instead of  an excel file is that the DB is a shared one and managed by an application, with the quality control.

 

In any case, thks for confirming the idea.

Rgds.

Jose Marin


Reply