【问题标题】:Visual Basic 2010 DataSetVisual Basic 2010 数据集
【发布时间】:2011-11-18 18:40:29
【问题描述】:

我正在使用 Visual Studio 2010,并且正在处理 Windows 应用程序表单。我正在为我们的数据库而苦苦挣扎。我可以在网格视图中连接和检索数据。

但我不想显示记录 - 我想将特定行列放入变量中(简而言之,我想使用它)。 我的DataSet 被称为ProductionDataSetTable 被称为 Employee 并有四列称为 EmployeeFirst_NameLast_NameStatus

我现在如何存储变量 x 中的第 4 列和第 5 行中的条目?

【问题讨论】:

    标签: vb.net ado.net dataset


    【解决方案1】:

    连接到数据库后,您需要将数据放入 DataTable 中,然后操作 Row Items

    ' DataSet/DataTable variables
    Dim ProductionDataSet As New DataSet
    Dim dtProductionDataTable As New DataTable
    Dim daProductionDataAdapter As New OdbcDataAdapter
    
    ' Variables for retrieved data
    Dim sEmployee As String = ""
    Dim sFirstName As String = ""
    Dim sSurname As String = ""
    Dim sStatus As String = ""
    
    'Connect to the database 
    ''
    
    'Fill DataSet and assign to DataTable
     daProductionDataAdapter.Fill(ProductionDataSet , "ProductionDataSet")
     dtProductionDataTable = ProductionDataSet.Tables(0)
    
    'Extract data from DataTable
    ' Rows is the row of the datatable, item is the column
    
     sEmployee  = dtProductionDataTable.Rows(0).Item(0).ToString
     sFirstName  = dtProductionDataTable.Rows(0).Item(1).ToString
     sSurname  = dtProductionDataTable.Rows(0).Item(2).ToString
     sStatus  = dtProductionDataTable.Rows(0).Item(3).ToString
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-05
      • 1970-01-01
      相关资源
      最近更新 更多