|
-
Nov 4th, 1999, 06:09 PM
#1
Thread Starter
Addicted Member
I am using VB6.
I have bound my DataList1 to the Adodc1 data control.
Is it possible to add data from DataList1 to DataList2 ?
If so what code would I use ?
-
Nov 4th, 1999, 08:42 PM
#2
Junior Member
What is the RowSource for DataList2 (another ADO data control, based on some table)? Do you want to update this table?
-
Nov 4th, 1999, 08:49 PM
#3
Thread Starter
Addicted Member
Yes, DataList 2 is bound to another Data Control which is linked to a different table. I want to update this table.
What are the possibilities ?
-
Nov 4th, 1999, 09:04 PM
#4
Junior Member
Assuming (for simlicity) both tables have only one field ("fld") which is a ListField for both DataList controls, you can try this:
If Not IsNull(DataList1.SelectedItem) Then
Adodc1.Recordset.Bookmark = DataList1.SelectedItem
Adodc2.Recordset.AddNew
Adodc2.Recordset!fld = Adodc1.Recordset!fld
Adodc2.Recordset.Update
Else
MsgBox "Please, select an item.", vbExclamation
End If
This is an idea, you can customize it for your needs.
Hope that helps. Best regards, Vlad
-
Nov 4th, 1999, 09:37 PM
#5
Thread Starter
Addicted Member
Thank you vlad, that was excellent.Can you help me further please ?
I have 10 names in DataList1 and I want to move 5 into DataList2 Before I update the Table linked to DataList2. How can I achieve this transfer from one DataList Box to another.
-
Nov 4th, 1999, 11:22 PM
#6
Junior Member
You can use batch updates, if they are supported by your database provider.
Try the following:
1. Set LockType property for Adodc2 to adLockBatchOptimistic.
2. Remove Adodc2.Recordset.Update from the click event for the button you use to transfer items from one list for another.
3. Add another button for updating Table2, put Adodc2.Recordset.UpdateBatch for the click event for this button.
You can use Adodc2.Recordset.CancelBatch to cancel updates.
Another option could be using standard list box controls instead of DataList. In this case you can fill the first list programmatically, and then, when the user transfers some items to the second list, programmatically add them to the second table.
Vlad
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|