asp.net - DataTable.Select("ColumnName IN ") Guid error -


I am having problems with a DataTable line, the idea is that I have any rows from one line of rows I want to remove where one of the column values ​​is in the grid's set. However, I'm getting a grid / string comparison error from the selection () function.

The code is as follows:

  Slow sb for each line as new stringbilder as dtData.Rows in the DataRow sb.Append ("'sb.Append (Line ("SomeField"). ToString) sb.Append ("',") Next gvDataView.DataSource = dtSubData.Select ("SomeField IN (" & Amp; sb ToString.TrimEnd ("," .ToCharArray) & amp; ; ")")  

However, as someField is a unique identification column, dtSubData.select is throwing an error about Guid string comparison, keeping this in mind, Can I work on this issue?

If you can use Net 3.5 and System.Data.DataSetExtensions.dll, you can take advantage of LINQ here. First, I populate a hashet with values ​​from the DataData.

dtData.AsEnumerable () Select row from row. Field ("SomeField ") Val valid value = new hashset & gt; Guid & gt; (item);

Sorry for C #, but my VB LINQ syntax is slightly unstable. Anyway, after you have a hashset of valid ID, you can test efficiently whether the data from your second datatel is included in that set:

  gvDataView.DataSource = Row From dtSubData.AsEnumerable () where valid values ​​are. Insert (line.field & lt; Guid & gt; ("SomeField"));  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -