Arrays
-
I am trying to create an order form for my users. The form has a listbox where the user selects multiple names and it populates a textbox for user confirmation. The selection process also creates an array used to create a SQL database record for each name in the list. This part works. Here is the code I have so far:
Sub xxx
reader1 = dr1.ExecuteReader()
While reader1.Read()
values1.Add(reader1.Item("Name"))
values2.Add(reader1.Item("Emplid"))
End While
lbName.DataSource = values1
lbEmplid.DataSource = values2
End Sub
Sub xxx
rtbName.Text = Nothing
rtbEmplid.Text = Nothing
For i = 0 To lbName.SelectedItems.Count - 1
With arrList2
.ToArray()
End With
rtbName.Text = rtbName.Text & lbName.SelectedItems(i) & vbCrLf
Next
i = NothingThe problem I'm running into is, I need to collect the Emplid along with the name. I'm trying to set it up by selecting only the name with the Emplid selected at the same time. I can combine the two within the SQL statement, but I need to populate each field of the database entry separately. Any help would be greatly appreciated.:) Thank you,
LWhite
-
I am trying to create an order form for my users. The form has a listbox where the user selects multiple names and it populates a textbox for user confirmation. The selection process also creates an array used to create a SQL database record for each name in the list. This part works. Here is the code I have so far:
Sub xxx
reader1 = dr1.ExecuteReader()
While reader1.Read()
values1.Add(reader1.Item("Name"))
values2.Add(reader1.Item("Emplid"))
End While
lbName.DataSource = values1
lbEmplid.DataSource = values2
End Sub
Sub xxx
rtbName.Text = Nothing
rtbEmplid.Text = Nothing
For i = 0 To lbName.SelectedItems.Count - 1
With arrList2
.ToArray()
End With
rtbName.Text = rtbName.Text & lbName.SelectedItems(i) & vbCrLf
Next
i = NothingThe problem I'm running into is, I need to collect the Emplid along with the name. I'm trying to set it up by selecting only the name with the Emplid selected at the same time. I can combine the two within the SQL statement, but I need to populate each field of the database entry separately. Any help would be greatly appreciated.:) Thank you,
LWhite
Larry White wrote:
values1.Add(reader1.Item("Name")) values2.Add(reader1.Item("Emplid"))
I suspect you want to create a struct which connects these two values and build a collection of those structs.
Larry White wrote:
With arrList2 .ToArray() End With
Why would you do this to call one method ?
Larry White wrote:
lbName.SelectedItems
Items in a combobox can also have a value stored against them, you can store the Id there.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Larry White wrote:
values1.Add(reader1.Item("Name")) values2.Add(reader1.Item("Emplid"))
I suspect you want to create a struct which connects these two values and build a collection of those structs.
Larry White wrote:
With arrList2 .ToArray() End With
Why would you do this to call one method ?
Larry White wrote:
lbName.SelectedItems
Items in a combobox can also have a value stored against them, you can store the Id there.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
I am a relative beginner at VB.NET so my methods may be a little off. I am trying to pull the data from 2 fields from 1 table and creating a new record with name and employee id. I thought it would be a relatively simple process to capture an array with the name and ID, then use the array in the SQL insert variables to create each record. Thank you for responding,
LWhite