从(I = to rowcount -1)中选择并填充文本框然后填充到下一个文本框 [英] Select and populate textboxes then to the next from ( I = to rowcount -1)

查看:106
本文介绍了从(I = to rowcount -1)中选择并填充文本框然后填充到下一个文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我真的想压缩我的代码,我认为在审查了之前的许多讨论之后,这一切都很好。



我的项目搜索数据库并执行行计数。之后,它会提取两个必要的信息字段(EmployeeName,EmployeeNumber)。



以下代码不起作用的原因是什么?



Hello,

I would really like to compress my code and I thought it was all good after reviewing many previous discussions.

My project searches a database and performs a row count. Afterwards it pulls two necessary fields of information (EmployeeName, EmployeeNumber).

Any reason why the code below doesn't work?

For i As Integer = 0 To RowsCount - 1
       Me.Controls("Me.tbxEmployeeName" & (i + 1).ToString).Text = LoadDataSet.Tables("Getting Info").Rows(i).Item("FullName")
       Me.Controls("Me.tbxEmployeeNumber" & (i + 1).ToString).Text = LoadDataSet.Tables("Getting Info").Rows(i).Item("EmployeeNumber")





Me.Controls。部分不起作用,因为当我分配文本框名称时,它会从数据库中提取正确的信息。



我尝试了什么: < br $>




The "Me.Controls." section isn't working because when I assign the textbox name it pulls the correct information from the database.

What I have tried:

Dim LoadSQL As String = "SELECT * FROM qryLocationPayrollList"
Dim LoadAdapter As New OleDbDataAdapter(LoadSQL, conIeam)
Dim LoadDataSet As New DataSet
Dim RowsCount As Integer

        If conIeam.State = ConnectionState.Closed Then
            conIeam.Open()
            LoadAdapter.Fill(LoadDataSet, "Getting Info")
            RowsCount = LoadDataSet.Tables("Getting Info").Rows.Count
            If RowsCount < 1 Then
                MessageBox.Show("No Reocrds Available", "SE-HUB Message Manager")
                LoadDataSet.Reset()
                conIeam.Close()
            Else
                For i As Integer = 0 To RowsCount - 1

                    Me.Controls("Me.tbxEmployeeName" & (i + 1).ToString).Text = LoadDataSet.Tables("Getting Info").Rows(i).Item("FullName")
                    Me.Controls("Me.tbxEmployeeNumber" & (i + 1).ToString).Text = LoadDataSet.Tables("Getting Info").Rows(i).Item("EmployeeNumber")

                Next
            End If
            LoadDataSet.Reset()
            conIeam.Close()
        End If

推荐答案

因为 - 正如RyanDev所说 - 我们不知道它是什么要做,并且不工作没有告诉我们你实际上在做什么,你没想到,或者没有做到你做过;当你说因为当我分配文本框名称时,它从数据库中提取正确的信息我们根本不知道为什么这应该是一个问题;我们真的无能为你提供帮助。



所以,它取决于你。

放一个断点在函数的第一行,并通过调试器运行代码。然后查看您的代码,并查看您的数据并找出手动应该发生的事情。然后单步执行每一行检查您预期发生的情况正是如此。如果不是,那就是当你遇到问题时,你可以回溯(或者再次运行并仔细观察)以找出原因。


对不起,但我们不能为你做到这一点 - 时间让你学习一门新的(非常非常有用的)技能:调试!
Since - as RyanDev has said - we have no idea what it is supposed to do, and "isn't working" tells us nothing about what it is actually doing that you didn't expect, or not doing that you did; and when you say "because when I assign the textbox name it pulls the correct information from the database" we have no idea at all why that should be a problem; there really isn't anything we can do to help you.

So, its going to be up to you.
Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!


这篇关于从(I = to rowcount -1)中选择并填充文本框然后填充到下一个文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆