I am facing an issue with Execute Query Activity. I have a simple select query (“Select * from Table1”) inside a while loop which runs fine on the first iteration. However, in the next iteration, it throws an exception “Execute Query: Object reference not set to an instance of an object”.
I then tried to use the Connect, Execute Query, and Disconnect activities. While doing this, again the first iteration went just fine. However, in the second iteration, the Connect activity threw an exception “Connect: External component has thrown an exception.”. I did supply the Database Connection handle to Execute Query and Disconnect Activities
UiPath Version: 2020.4.1
UiPath Database Activities Package version: 1.3.7369.25200
Database: MS Access
Your help would be greatly appreciated.
Object reference usually happens when you are trying to access a method, or a property and it currently returns null. You said that you have given the Execute Query activity inside the while loop. Check if the while loop is returning certain value from each iteration (if you are getting table names, for example).
Thanks for your response.
At this point, I just have:
- One while loop with condition “Counter < 5”
- Inside the while loop, I just have one Execute Query activity (which creates the connection as well) and a simple static SQL query “Select * from Table1”
To answer your question, no, my query is not dynamic at all. Let me know what you think could be the issue?
Alright then. Check the following:
- If a table named Table1 exists in your database.
- You have used the correct connection string.
- You have created a new instance of the output DT before entering the loop (if you are doing it dynamically)
Can you also post a screenshot of your error, if possible?