Vb.net 无法用供应商信息填充listview框

Vb.net 无法用供应商信息填充listview框,vb.net,visual-studio,visual-studio-2012,Vb.net,Visual Studio,Visual Studio 2012,加载表单时,会出现一个组合框,您可以在其中选择总账账户。一旦选择了一个,然后单击GetVendor按钮来加载供应商信息。我对form.vb上的代码有问题。我需要用供应商信息填充listview框,我不确定我做错了什么。我已经引用了应付款类库等。在form.vb上的vendor.count处出现错误。我还没有在appeadays.DB b/c上输入数据库信息,我不确定是什么。谢谢 Public Class Vendor Dim m_VendorName As Integer Dim m

加载表单时,会出现一个组合框,您可以在其中选择总账账户。一旦选择了一个,然后单击GetVendor按钮来加载供应商信息。我对form.vb上的代码有问题。我需要用供应商信息填充listview框,我不确定我做错了什么。我已经引用了应付款类库等。在form.vb上的vendor.count处出现错误。我还没有在appeadays.DB b/c上输入数据库信息,我不确定是什么。谢谢

    Public Class Vendor


Dim m_VendorName As Integer
Dim m_FirstName As String
Dim m_LastName As String
Dim m_City As String
Dim m_State As String



Public Sub New()

End Sub



Public Property VendorName() As String
    Get
        Return m_VendorName
    End Get
    Set(ByVal value As String)
        m_VendorName = value
    End Set
End Property

Public Property FirstName() As String
    Get
        Return m_FirstName
    End Get
    Set(ByVal value As String)
        m_FirstName = value
    End Set
End Property




Public Property LastName() As String
    Get
        Return m_LastName
    End Get
    Set(ByVal value As String)
        m_FirstName = value
    End Set
End Property

Public Property State() As String
    Get
        Return m_State
    End Get
    Set(value As String)
        m_State = value

    End Set
End Property

Public Property City() As String
    Get
        Return m_City
    End Get
    Set(value As String)
        m_City = value
    End Set
End Property
末级

    Imports System.Data.SqlClient
   Public Class GLAccount

Private m_Description As String

Public Sub New()

End Sub

Public Property Description() As String
    Get
        Return m_Description
    End Get
    Set(ByVal value As String)
        m_Description = value
    End Set
End Property

    Imports System.Data.SqlClient
     Payables
公共类供应商B

Public Shared Function GetVendors() As List(Of Vendor)
    Dim vendorList As New List(Of Vendor)
    Dim connection As SqlConnection = PayablesDB.GetConnection
    Dim selectStatement As String =
        "SELECT VendorName, FirstName, Last Name, State, City " &
        "FROM Vendor " &
        "ORDER BY Description"
    Dim selectCommand As New SqlCommand(selectStatement, connection)
    Try
        connection.Open()
        Dim reader As SqlDataReader = selectCommand.ExecuteReader()
        Dim vendor As Vendor

        Do While reader.Read
            vendor = New Vendor
            vendor.VendorName = (reader("VendorName")).ToString
            vendor.FirstName = reader("Firstname").ToString
            vendor.LastName = (reader("LastName")).ToString
            vendor.State = (reader("State")).ToString
            vendor.City = (reader("City")).ToString
            vendorList.Add(vendor)
        Loop
        reader.Close()
    Catch ex As SqlException
        Throw ex
    Finally
        connection.Close()
    End Try
    Return vendorList
End Function
末级

    Imports System.Data.SqlClient
   Public Class GLAccount

Private m_Description As String

Public Sub New()

End Sub

Public Property Description() As String
    Get
        Return m_Description
    End Get
    Set(ByVal value As String)
        m_Description = value
    End Set
End Property

    Imports System.Data.SqlClient
     Payables
公共级玻璃幕墙

Public Shared Function GetGLAccountList() As List(Of GLAccount)
    Dim accountList As New List(Of GLAccount)
    Dim connection As SqlConnection = PayablesDB.GetConnection
    Dim selectStatement As String =
        "SELECT Description " &
        "FROM GLAccounts " &
        "ORDER BY Description"
    Dim selectCommand As New SqlCommand(selectStatement, connection)
    Try
        connection.Open()
        Dim reader As SqlDataReader = selectCommand.ExecuteReader()
        Dim account As GLAccount
        Do While reader.Read
            account = New GLAccount
            account.Description = reader("Description").ToString
            accountList.Add(account)
        Loop
        reader.Close()
    Catch ex As SqlException
        Throw ex
    Finally
        connection.Close()
    End Try
    Return accountList
End Function
末级

    Imports System.Data.SqlClient
   Public Class GLAccount

Private m_Description As String

Public Sub New()

End Sub

Public Property Description() As String
    Get
        Return m_Description
    End Get
    Set(ByVal value As String)
        m_Description = value
    End Set
End Property

    Imports System.Data.SqlClient
     Payables
这就是我提到的应付款(表单和验证程序类)

末级

    Imports System.Data.SqlClient
   Public Class GLAccount

Private m_Description As String

Public Sub New()

End Sub

Public Property Description() As String
    Get
        Return m_Description
    End Get
    Set(ByVal value As String)
        m_Description = value
    End Set
End Property

    Imports System.Data.SqlClient
     Payables
公开课表格1 Dim供应商列表作为列表(供应商) 作为列表的Dim accountList(玻璃帐户)


末班

你的供应商在哪里。计数是你的问题……你需要在这里检查什么?Vender是您的类而不是集合…我想我想的是,如果选择的GL Account没有支付任何费用,它就不会出现在那里…有点像我运行的旧程序。将其取出,然后执行类似于:Do While VendorName.selected.item.add(Name.text)的操作。我将其取出,现在刚刚得到生成错误,其中我没有在appeadays.db上填写连接信息(显然)。除此之外,我是否需要在btnGetVendors_单击Other than vendorList=vendorList.DB.GetVendors()下的其他代码?这取决于您尝试执行的操作(完成)。单击“获取供应商”按钮时,我需要在列表视图框中填充vendorname、联系人姓名、城市和州。在VendorDB中,我可能需要将其更改为getvendorrents(ByAccountDescription)然后在from vendor后面添加一个参数---其中为account description
    Imports System.Data.SqlClient
   Public Class GLAccount

Private m_Description As String

Public Sub New()

End Sub

Public Property Description() As String
    Get
        Return m_Description
    End Get
    Set(ByVal value As String)
        m_Description = value
    End Set
End Property

    Imports System.Data.SqlClient
     Payables