Datarow throwing error

Hi everyone

My issue is I have a datatable with 6 rows of email address , out of which one is empty

There is another datatable so what i am doing is

OtherDatatable.select(“EmailID='”+in_Datarow(“EmailId”).toString+“'”).copydatatable

This in_Datarow is each row of that emailAddress datatable , so i when that empty row comes in picture like this , the above expression throws error source contains no datarow

Thanks in advance

Hi @kavya.s16

Try this expression

OtherDatatable.select("EmailID='"+If(in_Datarow.ToString.Equals(""),in_Datarow("EmailId").toString,String.Empty)+"’").CopyToDataTable

Regards
Gokul

Hi @Gokul001 i tried ur expression , i got invalid constant “”

what about this string.isnullorEmpty(in_Datarow(“EmailId”).tostring)

returns true for that empty email address in datarow

now how can i assign “” to a datarow?

Can you share the screenshot @kavya.s16

Regards
Gokul

Try to use this expression @kavya.s16

DtMaster.select("EmailID='"+If(String.IsNullOrEmpty(in_Datarow("EmailId").tostring),in_Datarow("EmailId").toString,String.Empty)+"’").CopyToDataTable

Regards
Gokul

still same error - The expression contains invalid string constant :‘’.
sorry couldnt share screentshot as its client data @Gokul001

Hi @kavya.s16

If possible can you share the sample XAML file

Regards
Gokul

@Gokul001 actually not possible as its client related :frowning:

Hi

Try something like this

dt = dt.AsEnumerable().Where(Function(a) a.Field(of String)(“EmailID”).ToString.Contains(
IF(String.IsNullOrEmpty(in_Datarow(“EmailId”).ToString), String.Empty, in_Datarow(“EmailId”).ToString)) ).CopyToDatatable

Cheers @kavya.s16

Hi @kavya.s16 ,

Are you trying to assign the Email value to the Original DataTable which doesn’t contain it?

Assuming that there is only a single instance of the Email Field being empty,you can first find the index of that empty row using this →

idx = OriginalDT.AsEnumerable().ToList().FindIndex(Function(f) IsNothing(f("EmailId").ToString) OrElse String.IsNullOrEmpty(f("EmailId").ToString))

Now that we have our index, all that is left is to assign the Email to that particular field using this →

OriginalDT.Rows(idx)("EmailId") = in_Datarow(“EmailId”).toString

Kind Regards,
Ashwin A.K

@kavya.s16 Why don’t you filter the empty values first if any, and then copy the values to other datatable ?