在VB.NET中检索数据

在VB.NET中检索数据,vb.net,Vb.net,非常新的VB.NET,所以请简单:)我目前正在处理一个旧的应用程序,我想知道你是否可以帮助我更有效地检索数据。下面的代码工作正常,但每次添加新的应用程序变量时,都需要对其进行修改,例如dim GROUP三、dim GROUP四等 Dim GroupOne As New Organisation(Application("testVar1")) Dim GroupTwo As New Organisation(Application("testVar2"))

非常新的VB.NET,所以请简单:)我目前正在处理一个旧的应用程序,我想知道你是否可以帮助我更有效地检索数据。下面的代码工作正常,但每次添加新的应用程序变量时,都需要对其进行修改,例如dim GROUP三、dim GROUP四等

Dim GroupOne As New Organisation(Application("testVar1"))
            Dim GroupTwo As New Organisation(Application("testVar2"))
            ddlGroups.AddDropDownListItem(GroupOne.Title, GroupOne.OrganisationID)
            ddlGroups.AddDropDownListItem(GroupTwo.Title, GroupTwo.OrganisationID)
            GroupOne = Nothing
            GroupTwo = Nothing
Dim myList As New List(Of Organisation)
            Dim Group As New Organisation(Application("testVar1"))
            myList.Add(Group)
            For Each Item In myList
                ddlGroup.AddDropDownListItem(Group.Title, Group.OrganisationID)
                Group = Nothing
            Next
基本上,我想知道是否有人可以建议一种更好的方法来检索变量数据(在DB表中)。我曾考虑使用一个列表,但到目前为止,我还没有实现它

Dim myList As New List(Of Organisation)
            Dim Group As New Organisation(Application("testVar1"))
            myList.Add(Group)
            For Each Item In myList
                ddlGroup.AddDropDownListItem(Group.Title, Group.OrganisationID)
                Group = Nothing
            Next
非常感谢

Dim myList As New List(Of Organisation)
            Dim Group As New Organisation(Application("testVar1"))
            myList.Add(Group)
            For Each Item In myList
                ddlGroup.AddDropDownListItem(Group.Title, Group.OrganisationID)
                Group = Nothing
            Next

Paul

如果在db中调用相同的应用程序变量,我会想到下面的情况,但尽管有两个实例,但它在下拉列表中只显示一个

Dim myList As New List(Of Organisation)
            Dim Group As New Organisation(Application("testVar1"))
            myList.Add(Group)
            For Each Item In myList
                ddlGroup.AddDropDownListItem(Group.Title, Group.OrganisationID)
                Group = Nothing
            Next
干杯
保罗相当含糊。什么是
ddlGroups
,这是Winforms吗?作为数据源的列表可能会简化事情。组织信息是否也存储在数据库中?如果是这样,为什么不使用查询填充下拉列表呢。如果没有,为什么不呢?它的赢形式是的,当im我想用存储在db中的应用程序变量填充一个下拉列表(ddlGroups)。应用程序变量的名称称为testVar1、testVar2等。添加新组织时,db是否会自动更新?你有办法查询数据库中的新变量吗?你好,是的,我可以查询数据库中的变量。我最初的想法是将变量命名为相同的名称,然后创建一个组织列表。但我无法让这个列表发挥作用——基本上,有一个名为“价值”的栏目与一个组织相关。我需要检索每个组织值,然后循环并取回有关该组织的数据。很难解释,抱歉,如果没有意义,干杯
Dim myList As New List(Of Organisation)
            Dim Group As New Organisation(Application("testVar1"))
            myList.Add(Group)
            For Each Item In myList
                ddlGroup.AddDropDownListItem(Group.Title, Group.OrganisationID)
                Group = Nothing
            Next