Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Field' is not a member of 'System.Data.DataRow'

Tags:

c#

vb.net

I am using VS2005 for vb.net. I am getting compile error at below statement. How to fix this?

    For Each rw As DataRow In data.Rows
        For Each dc As DataColumn In stringColumns
            rw.Field(Of String)(dc).Replace("_x00D_", "") //Error showing here
        Next
    Next
like image 672
James123 Avatar asked May 30 '12 04:05

James123


People also ask

What is datarow field in system data?

DataRow Field. Summary. We used DataRow in C# programs. This is a powerful collection in System.Data that will greatly help your program and keep its code understandable. The DataRow is used in almost every program that also uses the DataTable type.

How to use datarow and datacolumn in a DataTable?

Use the DataRow object and its properties and methods to retrieve and evaluate; and insert, delete, and update the values in the DataTable. The DataRowCollection represents the actual DataRow objects in the DataTable, and the DataColumnCollection contains the DataColumn objects that describe the schema of the DataTable.

How do I check if a datarow contains cells or fields?

Every DataRow will contain cells or fields. You will often need to examine these values while using DataTables in memory. Here we access the ItemArray on a DataRow, and then test each field in that row. Note: You can avoid casting with the Field generic method. Please see the section further down for more info.

Is there a way to define an item in system data row?

System.Data.DataRow' does not contain a definition for 'Item' and no extension method 'Item' accepting a first argument of type 'System.Data.DataRow' could be found (are you missing a using directive or an assembly reference?) I referenced System.Data Version 4 in both projects. What am I missing here? Note: ItemArray exists in both...


1 Answers

Add a reference to System.Data.DataSetExtensions.dll then your code will work. Field is a Extension method you need to add the reference otherwise it will not work.

VS 2005 with .net 2.0 ?

then you can't add reference to this dll. you need to target .net 3.5 or above to use these extension methods.

like image 70
Damith Avatar answered Sep 25 '22 14:09

Damith