Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read data from DataView 2

Status
Not open for further replies.

Andrzejek

Programmer
Jan 10, 2006
8,576
US

I have it working, but I am not sure if that's the best way to do it.

I create a table in my dataset:
Code:
[blue]
Private dvFileNumber As New DataView[/blue]

Dim strFile As String = "SELECT DISTINCT PSBRDG_PROJECTNAME, " _
    & " PSBRDG_PROJECTNUMBER, PSBRDG_FILE_NUMBER " _
    & " FROM S4111000.PSBRIDGE_INFORMATION"
[green]
'Create tblFileNumber in my dsDtSet[/green]
Call SetNewTableInDS(strFile, "tblFileNumber")
[blue]
dvFileNumber.Table = dsDtSet.Tables("tblFileNumber")[/blue]
I would like to use a DataView to filter my table to get what I want, but I need to populate a label. I know how to use DataView as a DataSource, but how do you get the data from DataView if you want to put this info into a label? Labels do not have DataSource.

For now I have:
Code:
For Each row As DataRow In dsDtSet.Tables("tblFileNumber").Select("(PSBRDG_PROJECTNAME = '" & cboPinNumber.SelectedValue & "') " _
    & " AND (PSBRDG_PROJECTNUMBER = '" & cboProjNumber.SelectedValue & "')")
    lblFileNo.Text = row("PSBRDG_FILE_NUMBER").ToString
Next
Filtering the table itself, which works fine.

I tried several variations of (code in red):
Code:
dvFileNumber.RowFilter = "(PSBRDG_PROJECTNAME = '" & cboPinNumber.SelectedValue & "') " _
    & " AND (PSBRDG_PROJECTNUMBER = '" & cboProjNumber.SelectedValue & "')"
[red]
lblFileNo.Text = dvFileNumber.Table.Rows(0).Item("PSBRDG_FILE_NUMBER").ToString   ...???[/red]

The [tt].RowFilter[/tt] works fine, it is just how do you get the data from DataView?

Or am I already *there* with [tt]Select[/tt] on the Table itself and should be happy with it? And forget about DataView in this case?


Have fun.

---- Andy
 
Is this what you are looking for?
Code:
        For Each drv As DataRowView In MyDataView
            MessageBox.Show(drv.Item(0).ToString)
        Next

You can also bind the text of a label to a datasource as well.
Code:
Me.Label1.DataBindings.Add("Text", MyDataView, "ColumnName")
 

Thanks RiverGuy. I knew I could count on you..... :)

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top