Cor,
Thanks again for the assistance. It is greatly appreciated.
I have actually created 2 datatables, although now I think my logic
may be flawed.
In my app, the user can fill out a form (actually contains multiple
chkdlistbxs) and save their responses to the db. Later, the user can
bring the form back up, edit their responses, and re-save the form to
the db. With this in mind, I decided to do this when the user opens
the form to edit:
1. Pull the info from the db, throw it into a dataset, and iterate
thru that to check the appropriate checks.
2. Let the user check, un-check, whatever on the form.
3. When the save changes btn is clicked, I then iterate thru the
controls and throw the selected items into another dataset.
From this point, I need to determine exactly what was changed
(mythought was to compare the 2 datatables to see what differed) in
their edit, while retaining the old values. These old values must be
marked as "Changed", and the new values inserted into the db.
If this is how you understood the problem, I will give the dataview
and stringbuilder a go.
Thanks much again for the help!!!!!
Daniel
On Wed, 1 Feb 2006 07:59:06 +0100, "Cor Ligthert [MVP]"
<(E-Mail Removed)> wrote:
>Frank,
>
>No just one, if I understood your problem well, have you created a datatable
>from your selecteditems in your checkedlistbox.
>
>What you can try to do as well using this checkedlistbox direct or that
>datatable can be
>
>\\\
>dim dv as new dataview(datatable1)
>dim selectstring as new io.stringbuilder
>For i as integer = 0 to checkedlistbox1.SelectedItems.count - 1 (or your
>datatable)
> dim item as string = checkedlistbox1.selectedItems(i).ToString (or
>your datatable item)
> 'if the one above does not go, than reply
> selectstring.add("YourColumname6 = ")
> selectstring.add(item)
> if i <> checkedlistbox1.selecteditems.count
> selectstring.add(" Or ")
> end if
>Next
>dim dv.datarowfilter = selectstring.ToString
>///
>Than should your dv gives the rows which are equal.
>
>See this code as a kind of pseudo I have typed in this message and use as
>you normally of course forever the intelisence.
>
>Cor
>
>"Frank" <noreply@nospam> schreef in bericht
>news:(E-Mail Removed)...
>>
>> Cor,
>>
>> Thanks for the response. As a daily lurker here, I can appreciate all
>> the help you dole out.
>>
>> Just to make certain I understand your response: I could (should)
>> create two dataviews and then compare them to see if they are equal?
>>
>> Also, I am not sure what Find method you are referring to.
>>
>> In the meantime, I will do some research on the datatable.Select for
>> more info.
>>
>> Thanks again!!!
>>
>> Dan
>>
>> On Tue, 31 Jan 2006 20:16:32 +0100, "Cor Ligthert [MVP]"
>> <(E-Mail Removed)> wrote:
>>
>>>Frank,
>>>
>>>Was it you wich I asked why you did not use a Find (there are two and you
>>>can use both for this).
>>>
>>>Although a simple dataview with a datarowfilter containing a builded
>>>string
>>>with Or will probably as well do the job.
>>>
>>>And than you have the possibility with the datatable.select.
>>>
>>>I think that I in this case would go for the dataview with a rowfilter.
>>>
>>>http://msdn.microsoft.com/library/de...iltertopic.asp
>>>
>>>While I would build that expression with a stringbuilder
>>>
>>>http://msdn.microsoft.com/library/de...classtopic.asp
>>>
>>>I hope this helps,
>>>
>>>Cor
>>>
>>>
>>>
>>>"Frank" <noreply@nospam> schreef in bericht
>>>news
(E-Mail Removed)...
>>>> Hello All,
>>>>
>>>> I am working on a vb.net app where I need to compare to 2 datatables
>>>> and determine if a string exists in one or both. The first dt is
>>>> filled from the db. A form is loaded and the appropriate items in a
>>>> checkedlist box are selected based on the dt. So far, no problem. Then
>>>> user can then edit the values in the checkedlist box and choose to
>>>> save changes. When they save changes, I throw the new values of the
>>>> checked items from the checklistbox into a new dt and compare the two.
>>>> Posed a similar question a couple of weeks ago, and was going to try a
>>>> comparison based on a datarow but was stymied because the 2 dt's don't
>>>> match. Any help will be greatly apprecitated!
>>>> Here is some code:
>>>>
>>>> For i = 0 To myDSOrig.Tables(0).Rows.Count - 1
>>>> For z = 0 To dsChanged.Tables(0).Rows.Count - 1
>>>> If myDSOrig.Tables(0).Rows(i).Item(5).ToString =
>>>> dsChanged.Tables(0).Rows(z).Item(5).ToString Then
>>>> Exit For
>>>> Else
>>>> lblChg = New Label
>>>> lblChg.Text = myDSOrig.Tables(0).Rows(i)(5)
>>>> ...
>>>> End If
>>>> Next z
>>>> Next i
>>>>
>>>> This little routine works fine if more than 1 string does not match.
>>>> However, if only 1 string doesn't match, then it fails by capturing
>>>> the unequal string twice and one string that does match! ie:
>>>>
>>>> TIA,
>>>>
>>>>
>>>> Dan
>>>
>>
>