![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Apr 2006
Posts: 8
Rep Power: 0
![]() |
listbox selection
Hi I need help please
I have 2 listboxes and 2 tables The first listbox will retreive the items from table 1 and if needed will move it to the second listbox when moved to the second listbox it should be inserted in table 2 I just want to understand the idea .. am running out of time please can someone spare sometime to help me ...?? I would really appreciate it ... Thank you in advance |
|
|
|
|
|
#2 |
|
Newbie
Join Date: May 2006
Posts: 5
Rep Power: 0
![]() |
If you still need help, this is simple enough. The code should look something like this:
Sub Load_listbox1()
Dim row as DataRow
For Each row1 in table1.Rows
'0 is to represent the zero-based index of the column you're pulling from.
listbox1.Items.Add = Cstr(row1(0))
Next
End Sub
Sub Move_To_listbox2()
listbox2.Items.Add = listbox1.SelectedValue
End Sub
Sub Update_Table2()
'Delcare SQL Command and Connection parameters here
'The SQL code to update Table2 should look something like "INSERT INTO Table 2 (column_name = '" & listbox2.SelectedValue & "')"
'Then query against table2 and pull it into a dataset and from the dataset repopulate listbox2
Dim row as DataRow
For Each row in table2.Rows
'0 is to represent the zero-based index of the column you're pulling from.
listbox2.Items.Add = Cstr(row(0))
Next
End SubPlease note this sample code doesn't use ADO.NET so much as direct updating and querying. This code also assumes that your table objects are globally accessible by the code. If you're still around to ask questions, please do so. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|