的Visual Basic 2010数据集 [英] Visual Basic 2010 DataSet
问题描述
我使用Visual Studio 2010和我的工作Windows应用程序的形式。我挣扎与我们的数据库。我可以连接并在网格视图中检索数据。
I'm using Visual Studio 2010 and I'm working on a windows application form. I'm struggling with our database. I can connect and retrieve Data in the Grid View.
但我不想要显示的记录 - 我想提出一个具体的行列中一个变量(总之,我想与它的工作)。
我的数据集
叫 ProductionDataSet
。该表格
叫员工
并有四列名为员工
,将First_Name
,姓氏
和状态
。
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
. The Table
is called Employee
and has four columns called Employee
, First_Name
, Last_Name
and Status
.
我怎么现在店里可以说,在变量x 4列和行5项?
How do I now store lets say the entry in column 4 and row 5 in the variable x?
推荐答案
在您连接到你需要把数据放入一个数据表,然后操纵行项目DATABSE
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
这篇关于的Visual Basic 2010数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!