Link to home
Start Free TrialLog in
Avatar of Julianto
Julianto

asked on

datarow and datarowview difference ?

I am still confuse about datarow and datarowview in ADO.NET
Is there anybody can tell me which one is better for
   - Find single record
   - Select records
   - Updating, adding new records, and deletion
   - databinding ( textbox  and datagrid )
   - Data access speed
 
What is the differences, there must be something specific in application.
I am still new in the .NET.
Thanks in advance

Avatar of iboutchkine
iboutchkine

An alternative to getting row from DataSetis to create a DataRow object. You can
loop through the rows in a table and retrieve the values, as shown in this example:

Dim drProduct As DataRow
For Each drProduct In dsNWind.Tables.Item(“Products”).Rows
MsgBox(drProduct.Item(“ProductName”).ToString)
Exit For
Next

A DataView is an object that allows you to create multiple views of your data and that can be used for
data binding.  The flexibility it introduces is impressive because a DataView does not actually change the DataTable from which it is  generated. Instead, it offers a filtered window to the data. The following code shows how you can use the
DataView control to filter rows based on a column value (in this case, the FirstName and LastName columns):


Function DataViewTest()
   Dim adapter As New OleDbDataAdapter("Select * From Customers", _
   connStr)
   Dim ds As New DataSet()

   adapter.Fill(ds)

   Dim view1 As DataView = ds.Tables("Customers").DefaultView
   Dim view2 As DataView = ds.Tables("Customers").DefaultView

   view1.RowFilter = "'LastName' Like 'O%'"
   view2.RowFilter = "'FirstName' Like 'E%'"

   Dim i As Integer

   Debug.WriteLine("All LastNames starting with 'O'")
   For i = 0 To view1.Count - 1
      Debug.WriteLine(view1(i)("LastName"))
   Next

   Debug.WriteLine("All FirstNames starting with 'E'")
   For i = 0 To view2.Count - 1
      Debug.WriteLine(view1(i)("FirstName"))
   Next
End Function
Julianto ,

The basic difference between Datarow and DatrowView is that Datarow is used to access the rows if the source of data is  a datatable while datarowview is used if Row has to be accessed from dataview. In short what datarow is to a dataTable the same is Datarowview is to a Dataview.

Datarowview provides more customizable options over dataRow as the former is based on dataview(which is more customizable version of dataTable)

Julianto...I think it will help you ....

rgds,
Jyoti.
Avatar of Julianto

ASKER

Looks like datarowview-dataview offer better opportunity to customize our application, but is there something we sacrifice, if we use datarowview instead of datarow ?( Maybe the memory consumption, resources or something ).
ASKER CERTIFIED SOLUTION
Avatar of jyotisinha
jyotisinha

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial