Monthly Archives: June 2004

ADO.NET 2.0: DataView.ToTable DISTINCT!! Hooray Hooray!

Because I had to write a DistinctRows function last night, today I looked at the May bits of VS2005 to see if they had addressed this really obvious need, and indeed they did! Hooray hoorah!

OverLoads Public Function ToTable( _ ByVal distinct As Boolean, _ ByVal columnNames() As String _) As DataTable

Here’s the quick hack I wrote last night if you want to use it. It sorts the table on the keyfield then walks through it grabbing every row where the value of the key field changes and stuffing it into a new datatable that is returned. No rocket science. Just another one of those things I wonder why I had to write the code.

(note – the int32_key is in there as a reminder in case I need to create another one for non-int keys)

Public Function DistinctRows_Int32_Key(ByVal dt As DataTable, ByVal keyfield As String) As DataTable
  
Dim newTable As DataTable = dt.Clone
  
Dim keyval As Int32 = 0
  
Dim dv As DataView = dt.DefaultView
  
dv.Sort = keyfield
  
If dt.Rows.Count > 0 Then
    
For Each dr As DataRow In dt.Rows
     
If Not dr.Item(keyfield) = keyval Then
       
newTable.ImportRow(dr)
       
keyval = dr.Item(keyfield)
     
End If
   
Next
 
Else
   
newTable = dt.Clone
 
End If
 
Return newTable
End Function

Caricatures at Sea World

At Sea World, there were 3 caricature artists lined up doing drawings of people. Each artist had a very different style. For example, Steele Price got the “Hollywood movie star” artist. I sat for a pic with Renee Rieser and we got the artist that every politician fears – well, thank goodness we don’t have big ears. We got the “exaggerate everything” artist. I have never been unaware that I have a large nose… but those teeth and that little dangling chin! LOL! Well, I guess I smile a lot. Anyway, Renee and I are reversed when standing with the pic (and the artist who is holding it). The drawing on the left is Renee and the one on the right is [supposedly] me 🙂

The rain that never came

This is very typical for Vermont. Rich and I had planned to NOT WORK today and go play outdoors : hike, bike, or even paddle. However the forecast this morning said rain throughout the day. It is now 3:30, 60 degrees (brrr) and overcast so that would have been okay for a hike or a bike ride, though with the Lake Champlain water temp at about 53 and no wetsuits, paddling would have been out anyway. Regardless, it never rained. I’ve been in front of the computer all damned day. Aaach.

ListControl: “could not bind to the new display member”

This error message was thrown when trying to set ListControl.ValueMember=“mydatafield“

I know I had this problem once before and wasted a lot of time trying to solve it.

I found nothing helpful via google (though a hint about Oracle that referred to case sensitivity which I stupidly ignored since it was Oracle).

Finally it occured to me (as it has in the past) that the damned thing is case sensitive.

Just check what the datatable has as the column name and follow the casing exactly.

I thought I’d stick this here for the next poor sucker searching in Google for this problem.