Private Sub frmCustomerIncidents_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim customersarray As New ArrayList
customersarray = CustomerIncidentsDb.getCustomers()
With cboCustomer
.DataSource = customersarray
.ValueMember = "CustomerID"
.DisplayMember = "Company"
End With
End Sub
@@ The database part
Public Shared Function getCustomers() As ArrayList
Dim customerAL As New ArrayList
Dim cmdGetCustomers As New SqlCommand
Dim drCustomers As SqlDataReader
Dim errors As New clsErrorMessages
Dim sSqlSelect As String
sSqlSelect = "Select CustomerID, Company from Customers"
With cmdGetCustomers
.Connection = GetTechSupportConnection
.CommandText = sSqlSelect
.CommandType = CommandType.Text
End With
Try
cmdGetCustomers.Connection.Open()
drCustomers = cmdGetCustomers.ExecuteReader(CommandBehavior.Default)
Dim values() As Object = New Object(drCustomers.FieldCount) {}
While drCustomers.Read
drCustomers.GetValues(values)
customerAL.Add(values)
End While
Catch ex As SqlException
errors.SqlErrorMessage(ex)
Catch ex As SystemException
errors.SystemErrorMessage(ex)
Finally
cmdGetCustomers.Connection.Close()
End Try
Return customerAL
End Function