2011-09-16 118 views
0

我正在使用Visual Studio 2010,我正在开发一个Windows应用程序窗体。我正在努力与我们的数据库。我可以在网格视图中连接和检索数据。Visual Basic 2010数据集

但我不想显示记录 - 我想把一个特定的行列放在一个变量中(简而言之,我想要使用它)。我的DataSet被称为ProductionDataSetTable被称为Employee并且具有称为Employee,First_Name,Last_NameStatus的四列。

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

回答

0

后您连接到DATABSE你需要把数据放到一个DataTable,然后操作将行

' 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