Question

We are looking to iterate through a TableAdapter and pull out the values of each row in the TableAdapter from a particular column called ClassName. We will add additional columns later.

We have created the following with the DataSet designer:

DataSet Name:      DataSetSchedules
DataTable Name:    DataTableSchedules
TableAdapter Name: DataTableDataAdapterSchedules

The TableAdapter is setup like this:

Dim theTableAdapter As New DataSetSchedulesTableAdapters.DataTableTableAdapterSchedules

And is initially populated like this:

Private Sub TeacherSchedules_Init(sender As Object, e As EventArgs) Handles Me.Init

    ' Load the data from the database into the GridView.
    '---------------------------------------------------
    GridViewSummary.DataSource = theTableAdapter.GetDataByAll(TextBoxSearch.Text)
    GridViewSummary.DataBind()

End Sub

We would like to make use of the already created TableAdapter which is why we want to just loop through the TableAdapter.

We will be using this to create a list that will be displayed as part of an email message.

Can you show me what coding is needed to populate and loop through the existing TableAdapter pulling out the value from the ClassName data column?

I think it should be something like:

    Dim strClassName As String = ""
    Dim objAadapter As New DataSetSchedulesTableAdapters.DataTableTableAdapterSchedules
    Dim objDataTable As <What to I put here?> = objAadapter.GetDataByAll(TextBoxSearch)

    For Each row As <What to I put here?> In objDataTable
        strClassName = row.ClassName
    Next

But I don't know what to put in place of the angle brakets (<>)

Was it helpful?

Solution

Friend Function ValidateUserCode(ByVal ScannedUserCode) As Boolean
    Try
        Dim taOperator As New dsBusinessTableAdapters.GetOperatorTableAdapter, isUpdated As Boolean = True
        If taOperator.GetData().Count <> My.Settings.Zero Then
            For Each dr As DataRow In taOperator.GetData()
                Dim dbUserCode As String = dr.Item(1).ToString 'pass usercode index to readable variable
                If ScannedUserCode = dbUserCode Then ' UserCode EXISTS in database?
                    If GetOperatorDetails(dr) = isUpdated Then Return True 'YES,Get their Details and lets go!
                End If
            Next
            Return False
        Else : Return False 'for now...'show ADD NEW OPERATOR FORM? 'or have a default Admin Operator...
        End If
    Catch ex As Exception
        Return False
    End Try
End Function
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top