I am extracting table data from web page and fetching few column values through assign activity and store it in variableName. Now I am trying to insert the values(VariableName) to database columns using insert query but getting error.
below is the query I used.
in Execute Non Query activity:
“Insert into Tablename(columnName) values(” & VariableName & ") "
Also I try with
“UPDATE TableName SET ColumnName = " & VariableName & " WHere ColumnName is NULL”
Both are throwing error like Execute Non Query: Invalid column name ‘VariableName’.
Hello @nancy29
If you have space in column name then add column name like this : [column name]
And also check name of the column is exactly same as name of column in database.
Hi ,
I changed the insert query as below.
“Insert into tablename([ColumnName],[ColumnName1]) values(‘VariableName’,‘VariableName1’)”. The existing error got solved. But I am getting below error Since one of the Column Value is Date format. Can you please help on this.
Execute Non Query: Conversion failed when converting date and/or time from character string.
Convert your string variable into datetime coz in database you have specify column type as datetime
Or
You can change datetime column to string in database then above query will work
The error you are encountering in UiPath is likely due to incorrect string concatenation in your SQL query. To resolve the issue, you need to ensure that the value of VariableName is properly included in the query. Here’s the corrected format for your queries:
For the insert query:
“INSERT INTO TableName (ColumnName) VALUES ('” & VariableName & “')”
Make sure to replace TableName with the actual name of your table and ColumnName with the appropriate column name.
For the update query:
“UPDATE TableName SET ColumnName = '” & VariableName & “’ WHERE ColumnName IS NULL”