Thank you for your suggestions. I rearranged most of my variables to be local. I have another issue you may be able to help me on. I'm using the following code to perform a SQL SELECT to combine the first & last name, and the employee ID number to be used in a listbox. The user selects multiple names that are transfered to a textbox. When they are selected, the array is created, which is used to create a record in a SQL table (one entry per name). The problem I have is, I need to update the Employee ID field but haven't found the right code to extract the "emplid" data. The name field works fine.
Dim sql1 As String = "Select (LastName + ', ' + FirstName) As Name, emplid FROM Users ORDER BY LastName"
Dim strCommandText As String = "INSERT INTO Orders(OrderDate, DeliverDate, DeliverLocation, Name, Special, Comments, Rate, EMPLID, LoggedIP)" & "VALUES('" & strOrderDate & "','" & strDeliverDate & "','" & strDeliverLocation & "','" & strName & "','" & strSpecial & "'" & ",'" & strComments & "','" & strRate & "','" & strEMPLID & "','" & strLoggedHost & "')"
Private Sub lbName_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbName.SelectedIndexChanged
Dim i As Integer
editName.Text = Nothing
For i = 0 To lbName.SelectedItems.Count - 1
arrList2.Add(lbName.SelectedItems(i))
With arrList2
.ToArray()
End With
editName.Text = editName.Text & lbName.SelectedItems(i) & vbCrLf
Next
i = Nothing
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim i As Integer
Dim r As String
Dim x As String
editComments.Clear()
strComments = editComments.Text
Try
SqlConnection1.Close()
cnn1.Close()
SqlConnection1.Open()
' Create a name array from editName textbox; Used to create a new record for each name
For i = 0 To arrList2.Count - 1
strName = arrList2.Item(i)
x = arrList2.Item(i)
Dim strCommandText As String = "INSERT INTO Orders(OrderDate, DeliverDate, DeliverLocation, Name, Special, Comments, Rate, EMPLID, LoggedIP)" & "VALUES('" & strOrderDate & "','" & strDeliverDate & "','" & strDeliverLocation & "','" & strName & "','" & strSpecial & "'" & ",'" & strComments & "','" & strRate & "','" & strEMPLID & "','" & strLogge