Forum Discussion

cdouglas's avatar
cdouglas
Occasional Contributor
14 years ago

Compare ADOTables

I'm in need of assistance. I've written the script to create an ADOTable off of a DB table, call a Stored Proc to make updates to that DB table and then create another ADOTable of the same DB table. But now I'm at a standstill as to figuring out how to compare the two ADOTables to confirm the updates. I know about the DBTables.Compare against a Store but not so sure where to go with comparing the ADOTables. Any help anyone could provide is greatly appreciated.



(I'm still very green on Scripting, so please bear with me.)

7 Replies

  • cdouglas's avatar
    cdouglas
    Occasional Contributor
    Or does anyone know if it's possible to export the ADOTable results to a file so that I might be able to use the CompareFiles test action?
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    You know what I would suggest?  Rather than having the two ADOTables, have a DBTable in the stores of what the database table looks like before the update.  Then, run the update and run DBTable.Compare.  That would effectively do what you're asking without having to write any excess code.



    On your other question, yes, it is possible to write code to export the table data to a file for file comparison.  This will take a bit of code to do so, but it's not difficult stuff.  



    Feel free to ask for help if you need some guidance as you write.
  • cdouglas's avatar
    cdouglas
    Occasional Contributor
    Thanks, I'll try that too. Another question about the ADOTable script. How do I write it to pull a value that is NULL? Is it just like SQL, or can I enter Value = NULL? I've tried several different ways but can't tell if it's actually working because the test is still running after 30 minutes. I know that table has over 2.5 million rows so that's probably the cause for the prolonged duration but I would at least like to make sure I'm entering the request correctly.



    Thanks!!
  • cdouglas's avatar
    cdouglas
    Occasional Contributor

    Okay, well I figured out the whole pulling NULL values but I noticed that the message it's supposed to log...doesn't. Is it not possible for this to work? All I get is a line that reads "Result:1". I'd really like to be able to show the result as NULL. Even if I change the message to a straight "The value is NULL" I get the same "Result:1" response. What am I doing wrong?


    While Not Before.EOF



    If Before.FieldByName("BatchID").Value = NULL Then


    Log.Message CStr(Before.FieldByName("BatchID").Value)


    End If


    Before.Next

     



    WEnd







    Thanks!!

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    I'm not strongly familiar with your scripting language choice... but rather than checking if Value = NULL, try using the IsNull function.  That MIGHT be a better choice.



    I suspect that your function is simply returning without even hitting the IF statement.
  • Hi Courtney,



    Robert is right. Here is a quote from an MSDN Library article:


    Expressions that you might expect to evaluate to True under some circumstances, such as If Var = Null and If Var <> Null, are always False. This is because any expression that contains a Null is itself Null, and therefore False.





    Try using the following code:
     

    While Not Before.EOF
     

      If IsNull(Before.FieldByName("BatchID").Value) Then


        Log.Message "The value is null"


      End If 


    Before.Next 


    WEnd


    Does it help?
  • cdouglas's avatar
    cdouglas
    Occasional Contributor
    Ah, yes, that worked wonderfully. Thank you both for your help! :)