I need to obtain an mean value of Width column in a Dataview. I can walk
through the Dataview (see below).

How do I extract the values from Width column in the Dataview so they can be
added together?

Would it be better to use a datatable? If so same question.

Dim dt As DataTable = ds.Tables("tblWidths")

Dim dvWidths As New DataView(dt)

dvWidths.RowFilter = "FishSurveyID = " + Me.FishSurveyIDWidths.Text + ""

Dim x As Integer = 0

For Each drv2 As System.Data.DataRowView In dvWidths

x += 1

Next

RE: Dataview column values by ENIZIN

ENIZIN
Wed Sep 29 17:43:11 CDT 2004

Just off the top I think you can just use the column indexer:

myval += drv2(columnname)

Ian

"JD" wrote:

> I need to obtain an mean value of Width column in a Dataview. I can walk
> through the Dataview (see below).
>
> How do I extract the values from Width column in the Dataview so they can be
> added together?
>
> Would it be better to use a datatable? If so same question.
>
> Dim dt As DataTable = ds.Tables("tblWidths")
>
> Dim dvWidths As New DataView(dt)
>
> dvWidths.RowFilter = "FishSurveyID = " + Me.FishSurveyIDWidths.Text + ""
>
> Dim x As Integer = 0
>
> For Each drv2 As System.Data.DataRowView In dvWidths
>
> x += 1
>
> Next
>
>
>
>
>

Re: Dataview column values by JD

JD
Thu Sep 30 09:56:18 CDT 2004

Ian,

I tried this statement
myval += drv2("columnname") or myval += drv2(columnname)
and it did not like it. Anyother suggestions?

jd

"ENIZIN" <ENIZIN@discussions.microsoft.com> wrote in message
news:DD611B0C-20A1-45CB-81F4-2EE80610851F@microsoft.com...
> Just off the top I think you can just use the column indexer:
>
> myval += drv2(columnname)
>
> Ian
>
> "JD" wrote:
>
>> I need to obtain an mean value of Width column in a Dataview. I can walk
>> through the Dataview (see below).
>>
>> How do I extract the values from Width column in the Dataview so they can
>> be
>> added together?
>>
>> Would it be better to use a datatable? If so same question.
>>
>> Dim dt As DataTable = ds.Tables("tblWidths")
>>
>> Dim dvWidths As New DataView(dt)
>>
>> dvWidths.RowFilter = "FishSurveyID = " + Me.FishSurveyIDWidths.Text + ""
>>
>> Dim x As Integer = 0
>>
>> For Each drv2 As System.Data.DataRowView In dvWidths
>>
>> x += 1
>>
>> Next
>>
>>
>>
>>
>>



Re: Dataview column values by Beverley

Beverley
Thu Sep 30 12:15:00 CDT 2004

I just stumbled onto this while looking for something else... it may help you.

http://www.knowdotnet.com/articles/expressions-printable.html

Quote from above web page:

Dim x As Integer = CType(Ds1.Tables("LeaveTable").Compute("SUM(TotalLeaveUsed)",
"EmployeeID = " & lstEmployees.SelectedValue.ToString), Integer)
tbLeaveUsed.Text = x.ToString

So what we did was call the Compute method of the DataTable (which was LeaveTable in our
example). To use it, you just call the aggregate function (SUM, COUNT, AVG etc) and a
Filter expression. So essentially the above statement would read "Give me the Sum of all
of the TotalLeaveUsed Values in LeaveTable (where LeaveTable is a DataTable in Dataset
Ds1) where the EmployeeID Field equals the employee number we got from the Listbox".

> > "JD" wrote:
> >
> >> I need to obtain an mean value of Width column in a Dataview. I can walk
> >> through the Dataview (see below).
> >>
> >> How do I extract the values from Width column in the Dataview so they can
> >> be
> >> added together?