1

我们正在寻找遍历 TableAdapter 并从名为 ClassName 的特定列中提取 TableAdapter 中每一行的值。稍后我们将添加其他列。

我们使用 DataSet 设计器创建了以下内容:

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

TableAdapter 的设置如下:

Dim theTableAdapter As New DataSetSchedulesTableAdapters.DataTableTableAdapterSchedules

最初是这样填充的:

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

我们想利用已经创建的 TableAdapter,这就是为什么我们只想循环通过 TableAdapter。

我们将使用它来创建一个列表,该列表将作为电子邮件的一部分显示。

你能告诉我需要什么编码来填充和循环现有的 TableAdapter 从 ClassName 数据列中提取值吗?

我认为它应该是这样的:

    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

但我不知道用什么来代替角括号(<>)

4

1 回答 1

2
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
于 2013-09-02T07:06:16.230 回答