开发者

Visual Basic 2010 DataSet

开发者 https://www.devze.com 2023-04-05 14:34 出处:网络
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 t开发者_开发技巧he Grid View.

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 t开发者_开发技巧he 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. The Table is called Employee and has four columns called Employee, First_Name, Last_Name and Status.

How do I now store lets say the entry in column 4 and row 5 in the variable x?


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号