Parameters not working in Query

Hello guys,

I’m trying to create a query in Uipath but the where clause must have values from an input.

I already tried to create parameters but they are not working.

Already checked that my query hard coded works.

Here is my query: “SELECT name FROM users WHERE username = ‘@username’ AND password = ‘@password’”

Here you have a screenshot:

Thanks

Kindly rename the @password Parameter to password . When dealing with query parameters, you don’t need to add quotations between the parameter in your query. It should looks like:

“SELECT name FROM users WHERE username = @username AND password = @password

Thanks for the answer.

Tried password without @ and the query without quotations but when I try to access the row from that dataTable, it sends an error saying that there is no row inside the dataTable.

this is the full code:

The username and password for the query must come from those inputs

Can you verify if the query produce results? Seems you dont get error on execute query.
Can you check the value of data.Rows.count.tostring?

It returns 0 when I try to message data.Rows.count.tostring.

The strange thing is that this query works on my DB.

Maybe the values from the input box are not being updated for the parameters.

These are my parameters:

As you can see, I’m defining the parameters username to have the value of the variable username. The thing is the variable username starts NULL when the process starts and it only gets updated when the user inputs the username.

Could it be that the query parameters gets the results when the process starts?

It’s very strange.

If my query is this:

"SELECT nome, classflow_user, classflow_pass FROM users WHERE username = ‘alexandrepc112’ "

In the data.Rows.Count.ToString message it returns 1.

But if my query is this:

It returns 0!!

Why is this happening?

Alexander,

  1. Check the scope of your variables (username, password)
  2. Writeline before the execute query, **“select * from users wher username = '” + username + “'” then run it on your database.
  3. You can also add breakpoint on executequery then click debug so you can check the values of your variable.