Problem with SQL update

I have very strange situation with SQL update query.
This si query I used in many project but in last does not works.

“UPDATE studydelete SET stat=1 WHERE StudyID= '”+txtStudyID+“'”

I don’t get any error or anything else, just don’t want to update datatable. ???
I was tried all variation and nothing works.
StudyID variable is a string in format “03/12/2013” or “DTE124565”.

When I replaced txtStudyID with “03/12/2013” then UPDATE works.
I don’t know what is wrong but it is a very strange situation.

Regards
Steve

Can you check with a log message how the sql query is looking before using in the SQL activity?

Hi

Welcome to UiPath forum

Well it could be because of datatype mismatch between the variable mentioned and the table column type
Or
Sometimes the variable doesn’t hold any value
Check with log message before to this query activity and see the value of that variable whether it has or not

But to work with query, try something like this

"UPDATE studydelete SET stat = 1 WHERE StudyID = ' " + txtStudyID + " ' "

Or

Like this with a parameter passed to the query

"UPDATE studydelete SET stat = 1 WHERE StudyID = @StudyID"

Here studyID you can pass the value by creating IN argument in that query activity

Hope this helps

Cheers @Stevica_Zivanovic

@Stevica_Zivanovic

Welcome to the community

As others have suggested first try to print in log message to check if the query is as expected

Also when editing the wuery make sure you open the query in advanced editor rather that in sql edit screen…

Cheers

The problem is because I dont get any error log …

Nope, that is not work.

yes, I try that also

@Stevica_Zivanovic

Can you show the error screenshot if you are getting any

cheers

Did u try with this @Stevica_Zivanovic

The solution finally works for me is that I had to remove the empty fields I had in the variable.

txtStudyID2 = txtStudyID.TrimStart.TrimEnd

1 Like

@Stevica_Zivanovic

You can directly use strVariable.Trim as well. Which trims both the ends

Glad its resolved

Cheers

1 Like