Forum Discussion

Oferv's avatar
Oferv
Super Contributor
13 years ago

DDT.ExcelDriver exception

hi,

i'm running a script that is reading data from an excel file.

the script suppose to run for 30000 for loop cycles.last night i ran the script and at the morning i saw that it got stack at this function:




function CreateExcelDriver(Path, ColName)

{

  DDT.ExcelDriver(Path, ColName, true)  <---here is the line where it stack




i saw an exception message (see attached file)

now,the only thing i can think about is that i didn't close the excel object while looping should i?

or you can think of something else.the script managed to complete 44 loops so it seems like it ran for a while.



thanks

10 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    IIRC, DDT.ExcelDriver, like the DDT.CSVDriver, has a maximum number of connections you're allowed to open (65, IIRC).  So, if you're looping through many times creating a new instance of the driver each time, eventually you'll exceed that number of connections.



    For myself, I use CSV files for a lot of things.  If I need to use information within a CSV file for a number of different processes over a period of time, I usually open the driver, read the data into some object or in memory structure, and close the driver.  This keeps me from exceeding the number of connections.  You might want to consider the same, using something like and ODT object class or ODT.Data variable to persist the values from your Excel connection.
  • Oferv's avatar
    Oferv
    Super Contributor
    Hi,



    i'm trying to close the driver and i'm a little bit confused about what to write in the Driver.Name here is the script i'm running:




    function CreateExcelDriver(Path, ColName)

    {

      //Create Excel Driver

      Driver = DDT.ExcelDriver(Path, ColName, true)

      //Log["Message"]("Excel Driver Created")   







    function GetRecord(FunctionName)

    {

      //Get record from the excel file

      DDT["CurrentDriver"]["DriveMethod"](FunctionName)

    }





    function CloseExcelObj()

    {

      //Close the excel driver   

      DDT["CloseDriver"](Driver)

      Log["Message"]("Excel Driver Closed")

    }





    function CheckThatAllFilesAreInTheRightPlace()

    {                     

      InstallationPath = "C:\\Program Files (x86)\\xxx\\xxx\\bin\\"  

      if (aqFile["Exists"](InstallationPath + DDT["CurrentDriver"]["Value"]("FileList")))

          {                           

          Log["Message"]("File " + DDT["CurrentDriver"]["Value"]("FileList") +  " exists under " + InstallationPath);              

          }

      else

      {

         Log["Error"]("File " + DDT["CurrentDriver"]["Value"]("FileList") +  " does not exist under " + InstallationPath);        

      }     

                            

    }




    what suppose to be the Driver value under  DDT["CloseDriver"](Driver)??? i tried Driver and it didn't worked



    Thanks
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Send in the value of DDT.CurrentDriver.Name.



    By default, every DDT driver is assigned a unique name.  You can set that name manually when you create the driver or you can just use the system generated one.  To get a driver's name, you just need to call the Name property.



    Personally, so that I can easily track things myself, I assign the DDT driver name so that I can easily recall it later.



    Refer to http://smartbear.com/support/viewarticle/13852/ for more information about proper usage of DDT.CloseDriver.
  • Oferv's avatar
    Oferv
    Super Contributor
    o.k but does DDT["CloseDriver"](Driver.Name)

    does Name refer to the name of the Driver or i just need to type .Name?

    in my case is it Driver.Driver or Driver.Name?
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    In your case, the identifier of Driver is not known in the context of the function within which you are calling DDT.CloseDriver.  So, you will need to call DDT.CurrentDriver.Name. 
  • Oferv's avatar
    Oferv
    Super Contributor
    well... here's what i did and i get an error message says "The "" driver was not found"




    function CreateExcelDriver(Path, ColName)

    {

      //Create Excel Driver

      Driver = DDT.ExcelDriver(Path, ColName, true)





    function CloseExcelObj()

    {

      //Close the excel driver   

      DDT["CloseDriver"](DDT.CurrentDriver.Driver)

    }



    where do i get it wrong?



    Thanks






  • Hi Ofer,



    You need to use the Name property, not Driver.

      DDT.CloseDriver(DDT.CurrentDriver.Name);