[英]Visual Basic 2010 DataSet
I'm using Visual Studio 2010 and I'm working on a windows application form. 我正在使用Visual Studio 2010,并且正在使用Windows应用程序窗体。 I'm struggling with our database.
我在努力与我们的数据库。 I can connect and retrieve Data in the Grid View.
我可以在网格视图中连接和检索数据。
But I don't want to display the records - I want to put a specific row column in a variable (in short I want to work with it). 但我不想显示记录-我想在变量中放入特定的行列(总之,我想使用它)。 My
DataSet
is called ProductionDataSet
. 我的
DataSet
被称为ProductionDataSet
。 The Table
is called Employee
and has four columns called Employee
, First_Name
, Last_Name
and Status
. 该
Table
称为Employee
并具有四个列,分别为Employee
, First_Name
, Last_Name
和Status
。
How do I now store lets say the entry in column 4 and row 5 in the variable x? 现在我该如何存储变量x中第4列和第5行中的条目?
After you connect to the databse you need to put the data into a DataTable and then manipulate the 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.