Visual Basic 2010 数据集

发布于 2024-12-05 00:20:52 字数 367 浏览 0 评论 0原文

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

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

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

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.

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

够运 2024-12-12 00:20:52

连接到数据库后,您需要将数据放入 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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文