Arjan's World: September 2006
You are now being redirected to the new housing of Arjan's World. Click here in case nothing happens

Wednesday, September 20, 2006

VB.NET: Issues With Changing The DataType Of A Column

I'm working with a DataGridView that gets its data from a server somewhere on the network in the form of an XML document. Therefore it's an unbound grid (*) for which some processing has to be done behind the scenes (XML >> DataTable >> Binding by code). Now I noticed an amount somewhere could be changed by the user ending up in decimals, instead of the required whole numbers. Thinking this could be changed easily I naively did

dt.Columns.Add("Amount")
dt.Columns("Amount").DataType=GetType(Int32)


resulting in a nice

ArgumentException
Cannot change DataType of a column once it has data.


The solution - of course - was to first build a DataColumn object with the right Type and bind that to the DataTable:

Dim dc1 As New DataColumn
dc1.DataType = GetType(Int32)
dc1.ColumnName = "Amount"
ds.Tables(0).Columns.Add(dc1)


Learned something new, hopefully it wil help you too.



(*) Naturally, would the grid have been bound, the DataType would folow automatically from the underlying DataSource...

You are now being redirected to the new housing of Arjan's World. Click here in case nothing happens

Monday, September 18, 2006

GMail Offline ...

You won't see this one very often. And well, they still say it's in BETA isn't it?

image showing offline GMail

You are now being redirected to the new housing of Arjan's World. Click here in case nothing happens

An App A Day: Can You Deliver Every Night?

This came in via The Daily Grind:

A .NET coder promises to write a C# app every evening from scratch starting September 15, 2006, and share his results with us via .exe and source, available from his site. He even seems to be on webcam and available for chat while coding moment but because of time zone differences and my need for sleep I'm unable to join in.

Chekced his Magnifier, which looks quite OK, though it was written in 3 nights instead of one (but you're a whiner if you complain). I'm looking forward to his next contributions.

Keep an eye on his Download Section for the apps