Wednesday, August 24, 2005

The Fox is out of the bag

In the Visual FoxPro August Newsletter in a paragraph regarding the SouthwestFox conference Ken mentions: "Calvin's presentation will be on great demos of new language features being added to a future version of Visual Basic for data-centric .NET programming significantly based on Visual FoxPro technology."

On a related note, Paul Vick punches up the abstract on his PDC topic Visual Basic: Future Directions in Language Innovation

Hip hip, HOORAY!!!! And the crowd goes wild......

Wednesday, August 17, 2005

Back from vacation

Ahhhh. I love summer. This year we drove up the west coast from San Francisco to Seattle. The first day we made our way through the redwoods up to Humboldt County. We stopped in Eureka and stayed at the Carter House Inn. It was beautiful and lots of fun. It was foggy in the morning but it cleared up and was sunny and mild in the afternoon- typical Northern California costal weather for August.

We then headed up the coast into Oregon, stopping at every tourist trap along the way -- Confusion Hill, Trees of Mystery, and the Enchanted Forest (complete with concrete dinosaurs). We made our way up to a camground near Dune City, OR - 8 miles south of Florence - and camped there for two nights. We hiked to the beach in the morning -- pretty easy walk, actually -- and collected shells and played on the beach with the seal lions. It was just me, Alan and the lions -- no one else for miles. A man did come out of nowhere and strolled up to us. But he gave me some cool agate stones and a whole sand dollar he found on the beach. He was cool.

After our relaxing two days we headed up to Seattle via I-5 through Portland. We needed to meet a friend who was flying in that night for Alan's birthday. Of course the flight was delayed 2 hours (because she flew Alaska Airlines) and she missed the dinner party. I should have figured. Alaska is ALWAYS delayed no matter what time of year. You're better off flying SouthWest (if you don't mind being hearded like cattle).

The rest of the week we spent visiting friends in Seattle and going up to Victoria, Canada (yes we went to Butchart Gardens ;-)). It was cold and overcast in Seattle (naturally!) but Victoria was nice and sunny.

It's nice to be back home. Visiting other places really makes me appreciate where I live. Summer is still in full swing here in the East Bay and I'm looking forward to spending the rest of it at home. Well, maybe I'll go camping on Mount Diablo one weekend with my sister, but that's only a 20 minute drive ;-)

Monday, July 11, 2005

VB.NET as a dynamic, data language

Personally, I am very excited about what Paul says in his post here. This is one of the biggest reasons why I love VB.NET (and VFP), and it looks like there will be some very exciting things to look forward to after VS2005. Make sure to check out this paper (which Paul links to from his post) by Erik Meijer and Peter Drayton.

Monday, June 27, 2005

Back Home from DevTeach

Well I'm back home from DevTeach which was held in beautiful Montreal. If anyone was looking for the rest of the presentation demos and slides they are all up on the DevTeach site now. I met lots of new friends this trip that I hope to keep for a long time to come. Thanks to everyone at DevTeach for a wonderful conference!

Wednesday, June 08, 2005

VS/SQL-Server 2005 Release Date Announced

The release dates for the next versions of Visual Studio, BizTalk and SQL-Server were announced at Tech Ed to be the week of Nov. 7th. A few places to read about it are here, here and here.

Wednesday, June 01, 2005

Bonus Session at DevTeach

If you're coming to DevTeach, you should definately check out the architecture bonus session. I'll be sitting on a panel with a bunch of really cool architecture dudes. Plus Nick Landry is going to be the animator so it should be a lot of fun! Hope to see you there.

Tuesday, May 17, 2005

Make your .NET demos better with a TraceListener

Last night I was writing a sample application for one of my DevTeach sessions and I thought I'd share this little trick. If you've ever tried to fiqure out a speaker's sample code after the conference when you got home you'd appreciate this as well. Usually I just write copious amounts of comments in my code to help people but last night it dawned on me how I could add a very simple TraceListener to my application to easily display the application's sequence of events in a list box. This way the developer could see exactly what was going on at runtime without having to debug the code.

If you're unfamiliar with TraceListeners have a read here.

Trace listeners monitor the output of the Debug and Trace messages in an application. You can create custom listeners and then add them to the Debug or Trace Listeners collection on application startup quite easily:
Imports System.Diagnostics

Public Class Main
 ''' --------------------------------------------------------------
 ''' <summary>
 ''' Main enrty point for the application.
 ''' </summary>
 ''' <remarks>
 ''' </remarks>
 ''' <history>
 '''  [Beth] 5/16/2005 Created
 ''' </history>
 ''' --------------------------------------------------------------
 Shared Sub Main()
  '-- Registers a trace listener 
  Debug.Listeners.Add(New DemoAppTraceListener)

  Application.Run(New MainForm)
 End Sub
End Class
The idea for the DemoAppTraceListener class is very simple. I just want to globally broadcast the trace messages so that they could be displayed by the application anywhere. We can do this by declaring a Shared (static) event:
Imports System.Diagnostics

''' -----------------------------------------------------------------------------
''' Project  : DataCachingStrategies
''' Class  : DemoAppTraceListener
''' 
''' -----------------------------------------------------------------------------
''' <summary>
''' Globally broadcasts the trace messages in this demo which are displayed in the UI.
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
'''  [Beth] 5/16/2005 Created
''' </history>
''' -----------------------------------------------------------------------------
Public Class DemoAppTraceListener
 Inherits TraceListener

 Public Shared Event MessageReceived(ByVal e As MessageEventArgs)

 Public Overloads Overrides Sub Write(ByVal message As String)
  RaiseEvent MessageReceived(New MessageEventArgs(message))
 End Sub

 Public Overloads Overrides Sub WriteLine(ByVal message As String)
  RaiseEvent MessageReceived(New MessageEventArgs(message))
 End Sub

End Class

''' -----------------------------------------------------------------------------
''' Project  : DataCachingStrategies
''' Class  : MessageEventArgs
''' 
''' -----------------------------------------------------------------------------
''' <summary>
''' This EventArg is used to broadcast messages from the DemoAppTraceListener.
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
'''  [Beth] 5/16/2005 Created
''' </history>
''' -----------------------------------------------------------------------------
Public Class MessageEventArgs
 Inherits EventArgs

 Private m_msg As String = String.Empty
 Public ReadOnly Property Message() As String
  Get
   Return m_msg
  End Get
 End Property

 Public Sub New(ByVal msg As String)
  m_msg = msg
 End Sub
End Class
Now all you have to do is handle the event and display the messages. Oh, yea you also have to actually put Trace messages in your code now too!
Public Sub Foo
        Trace.Write("Entering Foo method")
.
.
.
End Sub
To display the messages in my demo I created an MDI parent and put a simple list box on the bottom. Then I just added a handler to the DemoAppTraceListener.MessageReceived event. I added the handler in the constructor because this code is hidden in the form designer region and people won't be distracted away from the demo code.
#Region " Windows Form Designer generated code "

Public Sub New()
 MyBase.New()

 'This call is required by the Windows Form Designer.
 InitializeComponent()

 'Add any initialization after the InitializeComponent() call
 AddHandler DemoAppTraceListener.MessageReceived, AddressOf Me.DisplayMessage
End Sub
.
.
.
Finally I added the few lines of code to display the message in the list box and select the last message:
Private Sub DisplayMessage(ByVal e As MessageEventArgs)
 Me.lstMsgs.Items.Add(Me.lstMsgs.Items.Count.ToString + ". " + e.Message)
 Me.lstMsgs.SelectedIndex = Me.lstMsgs.Items.Count - 1
End Sub
Another cool thing about using a TraceListener is that the developer can still copy/paste the code in the demo into their own applications without having to remove the Trace messages if they don't want to.

Now if you come to my data caching session at DevTeach you'll get to see the TraceListener in action! ;-)

Saturday, May 14, 2005

A component walks into a bar....

The component asks the bartender via .NET remoting:
"Gimme a beer"
Bartender:
"What kind of beer?"
Component:
"Just give me all of them one by one and I'll drink the one I like."

The component asks the bartender via Web Services:
"Gimme a beer"
Bartender:
"What kind of beer?"
The component thinks a minute.
"I didn't know you'd have more than one. I just want a beer."
Bartender:
"What kind of beer?"
Component:
"A plain one."
Bartender:
"What's plain beer? How about a bud?"
Component:
"Umm.. ok."
The component tries to take the beer but it slips onto the floor and the glass breaks.
Bartender:
"What's wrong with you?"
Component:
"I got a slippery SoapException."

Thursday, May 05, 2005

Refactor, refactor, REFACTOR!

So much for hiding the word "refactor" from VB.NET developers... (oh how I love the fact that it's spelled with a big fat exclamation point!!!!)

Have you taken a look at this new VB 2005 refactoring? I think this refactoring interface blows doors off the C# one. Everything is context sensitive right at your fingertips and all inline with the code editor -- no modal dialogs! And it's just a whole heck of a lot smarter about what you would want to do with the selected code. Any developer will be able to pick this up in two minutes. Thank you Microsoft for making such an awesome deal with Developer Express to provide us all with this free tool. (I think there's a C# one you can buy for $99.)

Thursday, April 21, 2005

Custom Exceptions and Remoting

I just thought I'd put up a reminder post about enabling the throwing of custom exceptions from your remote objects since this was a change from 1.0 to 1.1. It recently bit me in the butt when I was setting up a new system. If you need to throw your own exceptions from your remote objects that are hosted in IIS, you need to make sure that customErrors="Off" in your Web.config file. By default it's set to "RemoteOnly" which means it will work on your development machine, but not when clents requests are coming from remote machines.

Wednesday, April 13, 2005

Combobox Databinding Woes

UPDATE: This post is for Visual Studio 2003. For Visual Studio 2005 content please see this post.

I've been noticing a lot of questions on the newsgroups related to Winforms databinding and the combobox and I thought I'd post something up here to help people out. There are a couple very common scenarios in which people use the combobox:

1. To display information from a lookup table and send the selected value into another table's field.

2. To display a list of parent table's records and use that as a filter to display related child records. For instance, as the user selects a record in the combobox, you want to display all the related child records in a grid.

As usual, the trick is setting up the data binding properly and using the currency managers. In the first case it's not necessary to set up a data relation in your dataset between the lookup table and the table you're editing, but it doesn't hurt. In the second case it is necessary to create a relation between your parent and child tables. Let's take an example from our beloved Northwind:

Private Const SQL_CONNECTION_STRING As String = _
 "Data Source=localhost;" & _
 "Initial Catalog=Northwind;" & _
 "Integrated Security=SSPI"

Try
 Dim ds As New DataSet
 Dim cnn As New SqlConnection(SQL_CONNECTION_STRING)

 Dim da As New SqlDataAdapter("SELECT * FROM Region", cnn)
 da.Fill(ds, "Region")

 da = New SqlDataAdapter("SELECT * FROM Territories", cnn)
 da.Fill(ds, "Territories")

 ds.Relations.Add("Region_Territories", _
  ds.Tables("Region").Columns("RegionID"), _
  ds.Tables("Territories").Columns("RegionID"))

 ds.DataSetName = "RegionTerritories"

Catch Exp As Exception
 MessageBox.Show(Exp.Message)
End Try
In the first scenario we want to select a Region from the combobox and have that value populated into the Territorries record. In this case you'll need to set up the following properties on your Combobox:
Me.ComboBox1.DataSource = ds.Tables("Region")
Me.ComboBox1.DisplayMember = "RegionDescription"
Me.ComboBox1.ValueMember = "RegionID"
These properties control what items are displayed in the combobox and what value is used when the user makes a selection. Now to get that value into the Territories table, you'll need to set up a data binding:
Me.ComboBox1.DataBindings.Add("SelectedValue", ds, "Territories.RegionID")
Okay we're all set, right? Well... not exactly. You'll also need to call EndCurrentEdit on the territories currency manager at some point in order to write the value back to the dataset. Depending on the style of your form you could do this from an "Update" button (similarly you could call CancelCurrentEdit from a Cancel button). However, when working with datasets I find it much easier to use the dataset methods for Accepting/Rejecting row changes. So 99.99% of the time I just call EndCurrentEdit from the SelectedIndexChanged event handler of the combobox itself:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
 '-- This forces the comboxbox's value to be written to the dataset.
 Dim cm As CurrencyManager = DirectCast(Me.BindingContext(ds, "Territories"), CurrencyManager)
 cm.EndCurrentEdit()
End Sub
The cool thing (or anoying thing depending on how you look at it) about EndCurrentEdit/CancelCurrentEdit on the currency managers is that they cancel or commit only the fields in which they have bindings for where as the dataset rows' AcceptChanges/RejectChanges works on the whole row regardless of the data bindings. (It would be *really* nice if the currency manager had a property for this like "AlwaysCommitChanges" so we wouldn't have to call EndCurrentEdit all over the place.)

Now let's take our second scenario where we want to use the combobox as a row filter. In this case we have to have a relation set up between our parent and our child; in the example this is Region_Territories. The combobox properties can be set up just like the first example:
Me.ComboBox1.DataSource = ds.Tables("Region")
Me.ComboBox1.DisplayMember = "RegionDescription"
Me.ComboBox1.ValueMember = "RegionID"
Technically we don't need to specify the ValueMember property this time because we're not writing it anywhere, but it doesn't hurt to specify it. Next you'll need to set up the Datasource and DataMember properties of the DataGrid using the relation path. It is very important to get the path right otherwise the datagrid will not filter automatically as we move the position in the parent:
Me.DataGrid1.DataSource = ds
Me.DataGrid1.DataMember = "Region.Region_Territories"
Okay we're all set, right? Well... not exactly (I knew you were going to say that <g>). Unfortunately a combo box won't move the CurrencyManager's position for you like list controls do (Grids, Listboxes). So the trick is to get a hold of the parent currency manager and move the position manually by handling the combobox's SelectedIndexChanged event:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
 Dim cmParent As CurrencyManager = DirectCast(Me.BindingContext(ds, "Region"), CurrencyManager)
 cmParent.Position = Me.ComboBox1.SelectedIndex
End Sub
Because you set up the datagrid to display the related territories by specifying the relation path Region.Region_Territories as the DataMember, the grid will automatically filter it's rows based on the selected parent row in the combobox.

The currency managers are your friends. You can obtain currency managers for any table/path in your dataset even if there are no control bindings set. You can also use the currency managers to disable controls when the position moves to -1 (no records) Here's an example. The currency managers maintain dataviews so you can easily access the current DataView as well as the current DataRowView:
Dim dv As DataView = DirectCast(cmParent.List, DataView)
Dim dvr As DataRowView = DirectCast(cmParent.Current, DataRowView)
Complex winforms databinding can take some practice, but once you get the hang of it you can create some very cool forms. Have fun!

Stop the mailing list insanity!

Looks like I'm not the only one frustrated with unwanted email that won't unsubscribe! (Make sure you scroll to the diagram on page 3. WARNING: This may offend you.)

Friday, April 08, 2005

Sunday, April 03, 2005

I'd like to thank the academy...

This was totally unexpected and I just want to extend a personal thank you to Microsoft, GiftRAP, and especially the community!

Friday, April 01, 2005

Spoof someone for April fools!

http://www.msnsearchspoof.com/index.aspx

MSN Search celebrates April Fool's Day by introducing Spoof, a tool to let you create funny search results about a friend, family member, or co-worker. When you're done, you can send the page to the target or anyone else you think might get a laugh out of it.

Tuesday, March 29, 2005

Finally a hybrid that doesn't suck?

It's not like I hate the environment or anything (please, all I do in the summer is camp and mountian bike), it's just that hybrid cars are, well, sloooooow. I'm a car enthusiast and I've tweaked my Subaru WRX wagon to put it over the 350hp mark. It's a 4-cylinder turbo wagon that goes 0-60 in 4.9 seconds. That's respectible. Gas milage is 21mpg so that kinda sucks, but it isn't horrible. It's better than most SUV's on the market today (and I still have 4WD). I love my car. I just love cars.

I never thought these hybrid cars would really take off until two things happened. #1 - they were really fast. #2 - you can modify them. I admit #2 is not as important to most people, but I don't know many people who don't like power in their vehicle.

I came across the Lexus GS 450h today and it looks like Lexus has finally answered my #1 complaint about hybrids.

This new hybrid powertrain is unique to the GS 450h. It features a 3.5-liter V6 engine teamed with a high-output electric motor that, when combined, will produce "substantially" more than 300 horsepower, according to Lexus vice president of marketing Mark Templin. Lexus claims that this hybrid will be quicker than the new V8-powered GS 430, yet it should achieve fuel economy similar to that of a compact sedan with a 4-cylinder engine.

Only time and test driving will tell, but I think car manufacturers are moving in the right direction with these hybrids.

Sunday, March 27, 2005

Happy Easter!

Growing up Catholic (and 12 years of Catholic school!) I remember Easter as being a pretty big religious holiday. When me and my sister were kids, my mom used to make us cute little Easter outfits to wear to church. My sister was a little more into the cute dresses than I was but I do remember loving to wear those cool white bonnets with the long ribbons down the back. They also flew like frisbies if you threw them hard enough.

After Mass we used to go over to my Nona and Nono's (mom's parents) house and we'd have an Easter egg hunt. Nona would fill those plastic colored eggs with money and hide them in the yard. And I'm not talking dimes and nickels here, I'm talking paper money... $5, $10, even sometimes $20! The entire family used to participate, not just the kids (who wouldn't!). Though I do vaugely remember the kids got a head start.

One year, we all come back onto the patio and while opening our eggs and counting our money we see Nona hovering around us like she's looking for something. My mom asks her what she's looking for and she says that there's still a $20 egg out there somewhere. Now let me give you a little background on Nona's yard. Nona is one of the best gardeners I know (even today). She used to have beautiful tropical plants everywhere. She lived in Palos Verdies, CA overlooking the ocean and Catalina island. Her backyard looked like the Italian island of Iscia where she was from (off the Almafi coast). The yard was big. Real big. Real lush. Nona didn't make a treasure map. Whoops. We all looked for an hour and no money egg anywhere (though I do remember recruiting some more snails for my snail army). A couple years later while gardening, Nona finds the egg and the semi-decomposed $20 bill. But even the liquor store wouldn't take it when she tried to buy her lottery tickets. Great memories.

Although I'm not very religious now, Easter Sunday is still a day to spend with family eating and drinking (and drinking and drinking). This weekend has been really fun so far. My honey, Alan, is Jewish so he was very facinated with the whole Easter egg decorating. Friday was his first time. See, I usually go for an art deco look which basically involes throwing the eggs in as many colors as possible and then putting as many hideous stickers on them as I possibly can. Quantity, not quality, baby. Alan, on the other hand, took so much care in designing his eggs (all two of them). I do have to say that his were definate masterpieces. Of course, I had to break the news to him that my dad was just going to crack them open and eat them. But it was fun.

Later this afternoon we're heading over to mom's. Typically my mother makes enough gormet food to put Martha Stewart to shame. If 8 people are coming, she'll make food to feed at least 25. Now when we were kids we usually had some kind of roast or ham on Easter. When we got older the tradition changed to going out to a nice big brunch. This year Nona wanted to take it back home and cook. This year we're making rabbit. Yes, we're cooking up cute little easter bunnies and eating them. And if that's not enough, were also roasting a cute little lamb to go with the easter bunnies. My mom would never let Nona make this dish on Easter when we were kids because of the obvious freak-out factor, but we used to raise rabbits and I LOVE LOVE LOVE rabbit. And the way my Nona makes it is amazing. I can't wait!

I know my family is not normal, but we all love eachother very much and that's what these religous holidays mean to me nowadays... getting together with the people you love most in this world and having a good time. HAPPY EASTER EVERYONE!

Sunday, March 20, 2005

Podcasting to Fame

Carl's in the news about podcasting! If you haven't seen the DNR or Monday's shows you're definately missing out on some awesome podcasts. Carl's now setting up a customizable podcast called The Daily Commute. I can't wait to try this out.

Friday, March 18, 2005

Come to DevTeach 2005 in Montreal!

I'll be speaking at DevTeach 2005 this year in beautiful Montreal June 18-22. If you missed out last year, you should definitely consider it this year. I had a blast and those wonderful Canadians are so hospitable. I'm very excited to be coming back. Check out my sessions topics here and here. I'm doing a two parter with Nick Landry (aka Mobile Man) on designing distributed apps for multiple user interfaces. These sessions are going to be very "how to" focusing on a lot of different issues developing usable enterprise information systems. I can't wait!

DataSet Debugger Visualizer for VS 2003!

I don't know how I missed this one. This is probably my most favorite VS 2003 add-in to date. Anyone doing database development in .NET is probably using the DSWatch add-in. This add-in lets you select a dataset variable while in the debugger and presents a form with an XML representation of the dataset's data (as well as a datagrid).

Well say goodbye to DSWatch and hello to the XML Visualizer! This add-in rocks! Among the cool features it lets you view the schema of your dataset as well as the row versions. It also works on DataViews or any XML serializable type! Who needs to wait for Whidbey? Get this now!