I can't run a SQL query after a successful connect hitting "Only one of the connections can be used"

This is in Web Studio. I am trying to reproduce a running automation from the standalone client in the cloud. I am creating a “Microsoft.Data.SqlClient” connection and then attempting to run a SQL query with it and every time I do get this error at the SQL step:

2025-03-12 16:28:05.968 GMT−4:	Error: System.ArgumentException: Only one of the connections can be used.
   at UiPath.Database.Activities.ExecuteQuery.HandleException(Exception ex, Boolean continueOnError)
   at UiPath.Database.Activities.ExecuteQuery.ExecuteInternalAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
   at UiPath.Database.Activities.AsyncTaskCodeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
   at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

I am testing on my local machine and I can connect to the server in question via SQL Server Management Studio and run this same query. I have no DSNs defined for this database anywhere and have closed out any possible connections to the server like SSMS.

The connection string is:
Data Source={myServer};Initial Catalog={databasename};Integrated Security=True;Encrypt=False

And the creates a “Database connection” object

I then created a DatabaseConnection-typed variable with a default value of “new UiPath.Database.DatabaseConnection” and used that as my “Existing connection” value.

There is only one connection defined. If I put a disconnect command after the connect, the disconnect runs fine. It’s only the SQL that fails.
Anyone run into this and know how to resolve it or is this a bug?

Ok, so if I check the “Continue on error” radio button it works but the question still stands. Why the error in the first place. I shouldn’t have to bypass a legitimate error without handling it in some way.

Continue on Error isn’t making it work, it’s just preventing it from throwing the exception. Check and see if you have your database connection variable defined more than once.

@Freymish

try to disconnect from database from your system and try to execute it again

If you got solution please mark my post solution.

Happy automation!!

Of this I am aware. :frowning: Bad phrasing on my part.

Still doesn’t work this morning either. There is only one auto-generated variable for this connection.

Ok. I deleted and re-created the SQL run step and recreated it. Now it’s working.

Basically, I turned off and turned it back on.

2 Likes

Yeah that sounds about right.

:laughing:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.