Vijay_Gupta
(Advanced Member)
03/31/12 10:26 PM
Datatable.export failed!!

In my scripts, I usually export the datatable several times to prevent the loss of data in case of test failure.

Sometimes, I get an error on the line of exporting the datatable which says that "Datatable.export fails because the file is open in other application"

But I know that file is not open in any other application. I also checked Task Manager and excel.exe process is not there.

When I click on Retry button, it does not give any error and works fine.

Can anyone please let me know, why it happens at the first place?


ManishBansal
(Active Member)
04/02/12 01:23 AM
Re: Datatable.export failed!!

try these

1) I prefer ProcessExplorer then Task Manager to investigate excel process.

2) Windows > RUN > "tskill excel" without quotes (Manually)
Or create a script which kill all running excel instance before exporting (google you will find ready-mate script)

3)Restart your qtp and check if it reproducible
4)Restart compute and check
5)check your scripts on other computer
6)check for latest available patches
7)use latest qtp version

And finally if not fixed, raise case at HP, its simple and quick



I was getting the same issue, fortunately i am no more using QTP datatable, instead my COM data-datable, which fast and reliable


Vijay_Gupta
(Advanced Member)
04/02/12 09:58 PM
Re: Datatable.export failed!!

Thanks manish for the reply. I deployed a script before export that kill all the excel processes but it could not find any excel process before export (I msgboxed if it did not find any) and it happened again.

Tried restarting qtp, computer, I have all the latest patches (can you be more specific regarding the patches) and latest qtp 11 version.

Also, I forgot to mention that this issue is very random in nature. when it starts happening, then it happens persistently otherwise not.

"I was getting the same issue, fortunately i am no more using QTP datatable, instead my COM data-datable, which fast and reliable" Can you please let me know, what is COM datatable?


lockdown
(Member)
04/03/12 02:47 AM
Re: Datatable.export failed!!

If it's random then I would suggest wrapping this into a function, and loop around the export until it works.

something like this might help (coded off the top of my head so apologies for any errors - place this into a function or where your export code is):

Code:

Dim blnFlag : blnFlag = false
Dim n
on error resume next
do while (not blnFlag )
err.clear
'try to export
Datatable.export("C:\wherever.xls")
if err = 0 then
blnFlag = true
else
n = n + 1
wait(1)
if n = 10 then
'output some kind of error and break the loop
blnFlag = true
end if
end if
loop
on error goto 0



Vijay_Gupta
(Advanced Member)
04/03/12 11:51 PM
Re: Datatable.export failed!!

@ lockdown - do I need to change the line number in "on error goto 0" to something else?

lockdown
(Member)
04/04/12 12:58 AM
Re: Datatable.export failed!!

Hi Guptavijay, no you don't need to - On Error Goto 0 disables the "on error resume next" statement, so next time an error occurs it gets raised.

Vijay_Gupta
(Advanced Member)
04/04/12 02:23 AM
Re: Datatable.export failed!!

Thanks Lockdown for the workaround. I have opened a support case with HP for this issue and will update on this thread if I got any reply.

Meanwhile, if anyone has any suggestion why this issue is happening at the first place when no excel process is running, then please let me know.


ManishBansal
(Active Member)
04/06/12 02:35 AM
Re: Datatable.export failed!!

I have wrapped System.Data.DataTable into a COM object

Now I have functions like, import/export excel, delimited file

Cursor Functions, like MoveNext, MoveFirst, MoveLast, MoveTo

Row functions, like ReadCell, WriteCell, count

Column Functions, like add, remove, count exists etc

it is super fast, reliable, and handle 100ks and more rows with multiple columns very easily and efficiently.

and the most important is it does not hang QTP and mysystem :-D !!!

Unfortunatly, its not an opensource and internal assets, otherwise I would have shared it.


ManishBansal
(Active Member)
04/06/12 02:46 AM
Attachment
Re: Datatable.export failed!!

here you go...

Please find attachment (My COM screenshot)


MilesToGoBeforeISleep
(Super Member)
04/06/12 03:21 AM
Re: Datatable.export failed!!

Manish,

Good one.

u developed this COM object?.


ManishBansal
(Active Member)
04/06/12 03:22 AM
Re: Datatable.export failed!!

Yes!

karthikbhatnagar
(Member)
04/06/12 03:54 AM
Re: Datatable.export failed!!

very neat!!!!!!!!!!!!!!

manish, wanted to ask you something.. you said the COM object is a wrapper of Data.Datable. in your code (attachment) a new dataset is created based on excel file. how are these 2 related? also.. can your com object leverage a qtp datatable?


ManishBansal
(Active Member)
04/06/12 06:03 AM
Re: Datatable.export failed!!

questions appreciated!
But lets not hijack this thread i will open a new thread monday morning


ManishBansal
(Active Member)
04/09/12 06:54 AM
Re: Datatable.export failed!!

I think if i cant really share the code then what is the use of making another thread.

To answer your question karthik, it has nothing to do with QTP inbuilt DataTable object, but it works almost similar.

Still why I am doing this ? There are hundreds of good reasons why did i make this.
1) It gives me 100x more performance and stability.
2) I get instant and 100% support for bugfixes and enhancements (because its my own code )
3) there's no need to close excel files before loading/importing files to my COM datatable.
4) it just not only for excel reading but works with any type of delimited file, load tables from database directly and even more.
5) it gives internal DataTable compare functionality which works on lambada expression (65k rows with 255 columns gets compared in less then 1 minute, I doubt QTP v15 would be able to do it in 24 hrs )
6) allow multiple sets of tables, we call it TableGroup (like a dataset)

lastly, its not just a Datatable COM, but it has other several utility functions which we use day-in-day-out within our automation scripts. (as you might have seen in the screenshot)

This COM provides help us doing serious automation by adding endless possibilities , and achieve our ROI, quickly.



Contact Us | Privacy statement SQAForums

Powered by UBB.threads™ 6.5.5