Private Sub PopulateCustomer()
'//This procedure retriews all customers
Dim SelectProducts = New SqlClient.SqlCommand
Dim myReader As SqlDataReader
MyConnection = New SqlConnection(MyCONNECTIONSTRING)
SelectProducts = New SqlClient.SqlCommand("SELECT Name, DCLink FROM Client Order By Name", MyConnection)
MyConnection.Open()
myReader = SelectProducts.ExecuteReader()
myDataColumn = New DataColumn
myDataColumn.DataType = System.Type.GetType("System.Int16")
myDataColumn.ColumnName = "id"
myDataColumn.ReadOnly = True
myDataColumn.Unique = True
tblCustomer.Columns.Add(myDataColumn)
'==>>>
myDataColumn = New DataColumn
myDataColumn.DataType = System.Type.GetType("System.String")
myDataColumn.ColumnName = "CustomerName"
myDataColumn.AutoIncrement = False
myDataColumn.Caption = "Customer Name"
myDataColumn.ReadOnly = False
myDataColumn.Unique = False
tblCustomer.Columns.Add(myDataColumn)
If myReader.HasRows Then
Do While myReader.Read()
myDataRow = tblCustomer.NewRow()
myDataRow("id") = myReader.GetValue(1)
myDataRow("CustomerName") = myReader.GetString(0)
tblCustomer.Rows.Add(myDataRow)
Loop
Else
MsgBox("Customer Database is empty", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, "Load Customer")
End If
MyConnection.Close()
MyConnection = Nothing
myReader = Nothing
Dim Lookup As New Hashtable
<'--This is the area the error is occurred
[COLOR=DarkOrange] For Each Row As DataRow In tblCustomer.Rows
Lookup.Add("id", "CustomerName")
cboCustomer.Items.Add("CustomerName")
Next[/COLOR]
'--This is the area, the error is occurred>
End Sub