Q? How to Convert String to uniqueidentifier

I have an excel file with an “id” column and the data is a GUID and when I try to insert to database I get an Error alert saying

insert: Failed to convert parameter value from a String to a Guid

(I used read range excel to datatable and insert datable to database) And how to convert data type from string to uniqueidentifier. Can someone explain me to convert string to uniqueidentifier ?

The database I use is MSSQL.

Hi @Harpoon

Welcome to UiPath community

A unique identifier is a type of value that can be used to identify an object or a record uniquely. A unique identifier is also known as a GUID.

A string is a type of value that can store text data. A string can be converted to a unique identifier if it follows a valid GUID format.

use the Convert.ToGuid method. This method takes a string as an input and returns a unique identifier as an output. For example:

myString = "123e4567-e89b-12d3-a456-426614174000"

myGuid = Convert.ToGuid(myString)

Another way is to use the Guid.Parse method. This method also takes a string as an input and returns a unique identifier as an output. For example:

myString = "123e4567-e89b-12d3-a456-426614174000"

myGuid = Guid.Parse(myString)

Note : Both methods will throw an exception if the input string is not in a valid GUID format.

Check out this thread

Regards
Gokul

2 Likes

sorry i’m newbie Can you please explain how to retrieve the “id” column to determine the variable? for use Convert.ToGuid

Hi @Harpoon

Can you share the screenshot of your excel file and the workflow?

Have you tried with using the Read Range activity. This activity allows you to read data from an excel file and output a data table.

Regards
Gokul

i’m used the read range activity and i got datatable name dt and i dont know how to make columns “id” to variable becasue output read range is datatable for use convert.toguid

Sorry I can’t share workflow and excel because i’m not at my desk now.