I am trying to execute non-query by passing the connection string to the existing database connection. But the query is not executing. While debugging the code it doesn’t show the database connection in the local’s pane. Please check the images below and guide me to solve this issue.
What have you put in the properties window for the database connection?
If you are using an existing database connection make sure the argument is passed in correctly and is actually intialised.
If you have configured the connection within the activity, make sure that everything is set up correctly.
Hi @surya123,
i think you are using Update query, before that how you have configured your connection string, with windows authentication or sql username and password
Could you provide the properties of connection string which you have used.
Before using update query can you just query the database using execute query activity and see if you are getting the datatable.
Select * from tablename
From your image, it looks like the dbconnect is not intialised properly?
Where do you create the connection to the database?
Have you passed out dbconnect from the connect activity correctly?
“Data Source=WIN;Initial Catalog=Winbot;Persist Security Info=True;User ID=winforpa;Password=********”
I created the connection in the init stage of state machine and i passed it as argument in the process transaction
most of the times, object reference not set to an instance of the object error is associated with passing of arguments, I suggest you that check your arguments passed into workflow…paste a screenshot of the invoked workflow arguments, will check
did you try storing value of argument in a variable and then using it as existing DB connection
no, i didn’t
Could you please try it and let me know if it works, other way is pass the connection string as string argument to the workflow and in execute non query activity, use that arguement string in under connection string
Check that in the init stage - you have passed out the argument correctly and also associated it in the actual activity itself.
In many Invoke codes, I am passing the same DB connection and they are working fine except at this position
Ok, it could be an issues with the query / parameters your are using within it?
Make sure they are all declared properly or are able to be accessed correctly.
I gave connection string here itself then the code is working fine ,but when i give as argument it was not working
Hmm very strange, potentially re-invoke the invoke workflow and arguments?
If it is working in other components and your SQL works correctly then the problem is the importing of arguments.
In the same file i do have another execute query where i passed the same db connect argument and it is working fine there but not here
Delete the activity and re-add it That works for me sometimes if the query activity isnt working properly.
Exactly. Probably this is a bug UIPath