Thoughts from Dan Miser RSS 2.0
# Thursday, March 08, 2007
I read Scott Hanselman's well-written article HOW TO: Debug into a .NET XmlSerializer Generated Assembly. I can add a few more little (and most likely obvious) things to his article:
  • This still works in .NET 2.0.
  • If you just do an Add New Item to add a new Application Configuration File to your project in VS, you can just paste the debugging flags in, and the config file will get deployed to the application directory automatically.
  • You can just Step Into (F11) the call to x.Serialize, and you will be taken into the proper generated file. You may want to open the file manually as Scott mentioned, but I find it to be faster to press F11, and then go to the place in the file I want to debug.

In the end, we ended up writing our own serialization for .NET CF due to one too many bugs.

Thursday, March 08, 2007 2:26:21 PM (Central Standard Time, UTC-06:00)  #    Comments [0] -
.NET | XML
# Monday, March 05, 2007
I've been listening to more podcasts lately (e.g. .NET Rocks, Hanselminutes, etc.), and they certainly contain good information. When listening to podcasts on my PC via Windows Media Player, I tend to set the playback rate to a higher rate in order to compress time.

When playing back audio files on an iPod, you can do the same type of thing, but you have to know the secret. You need to have a 4th generation iPod, have your audiobook/podcast encoded as an AAC file, and change the Settings > Audiobooks setting in the iPod to Faster. After doing that, I am now traveling through time around 25% faster. :-)

Monday, March 05, 2007 1:14:42 PM (Central Standard Time, UTC-06:00)  #    Comments [1] -

# Wednesday, February 21, 2007
A while back, I wrote about how to use the Data Access Application Block (DAAB) in the Compact Framework. While this code works just fine, it turns out that Enterprise Library 3.0 will support this natively. I really like the TableExists method that they added, too.

David Hayden wrote a couple of articles about this here and here.

Wednesday, February 21, 2007 5:23:26 PM (Central Standard Time, UTC-06:00)  #    Comments [0] -
.NET | ADO.NET | Compact Framework
# Monday, February 19, 2007
The following code assigns DateTime.MaxValue to a parameter. When trying to run this code against the Northwind databse, it will produce the error, "An overflow occurred while converting to datetime".



SqlCeConnection conn = new SqlCeConnection(connStr);

conn.Open();

SqlCeCommand cmd = new SqlCeCommand("select * from employees where [Hire Date] < @paramDate", conn);

 

SqlCeParameter paramDate = cmd.CreateParameter();

paramDate.ParameterName = "@paramDate";

paramDate.DbType = DbType.DateTime;

paramDate.Value = DateTime.MaxValue;

cmd.Parameters.Add(paramDate);

 

SqlCeDataAdapter da = new SqlCeDataAdapter(cmd);

DataTable tbl = new DataTable();

da.Fill(tbl);

dataGridView1.DataSource = tbl;

 

conn.Close();

Note that this fails when using MSSQL Compact Edition (MSSQLCE) under a standard WinForm application and a Pocket PPC platform. The same code against a standard desktop MSSQL version will work fine.

The workaround is simple. Just get away from the MaxValue. Of course, this is a workaround, so it's not perfect, but it certainly works for my needs.


  paramDate.Value = DateTime.MaxValue.AddMilliseconds(-1);
Monday, February 19, 2007 9:37:16 AM (Central Standard Time, UTC-06:00)  #    Comments [0] -
.NET | ADO.NET
# Saturday, February 17, 2007

Sorry for the changing plans, but I just received word that CodeGear won't be able to make it out here for the 2/27 meeting so the DUG meeting will be cancelled. They may be able to reschedule in April, so that will give us some more lead time, but for now, things are off. Thanks for your understanding.

Saturday, February 17, 2007 10:08:54 AM (Central Standard Time, UTC-06:00)  #    Comments [1] -
Delphi
# Thursday, February 08, 2007
I was banging through some quick and dirty sample applications today, in preparation for a talk on LINQ tonight. One of my old LINQ to SQL demos shows how to use the external xml mapping file. I also blogged about this before. Today, I kept getting the following error whenever I would run with an external xml mapping file:
The type 'Order' is not an entity.

I was using the following command line to generate the xml mapping file:

SqlMetal /server:(local) /database:Northwind /map:Northwind.xml /code:Northwind.cs /pluralize

Looking at the resulting xml file, I finally noticed this section:


  <Table Name="Orders">
    <Type Name=".Order">

Notice the leading dot before the type name attribute. That's the problem. So I went back and added the /namespace switch to the sqlMetal command line, and now all is well with the world again. Granted, this problem is the result of me doing demo work, and not production work, but it's still a little bit irritating. Then again, I'm still running the May 2006 CTP on VS2005, so for all I know, MS has already fixed all of this with a subsequent release of a build in Orcas.

Thursday, February 08, 2007 1:23:16 PM (Central Standard Time, UTC-06:00)  #    Comments [0] -
.NET | LINQ
# Tuesday, February 06, 2007
I just received an email from Anders Ohlsson, and he wants to schedule Milwaukee as a stop on a 10-city tour. I take that as a positive sign that Milwaukee matters enough to warrant a stop. Let's keep that perception alive by coming out and attending this meeting! The very tentative details right now are:
  • What: Delphi User Group Meeting
  • When: Tuesday, 2/27/07 from 7pm-9pm.
  • Where: Medical College of Wisconsin
  • Why: Because you want to hear about updates on CodeGear, the roadmap and Delphi itself. CodeGear would also provide door prizes and a rebate offer.
  • How: RSVP by emailing me.

If you have any other thoughts, concerns, questions, etc., send me an email. I will post final details once we have them.

Tuesday, February 06, 2007 1:29:00 PM (Central Standard Time, UTC-06:00)  #    Comments [0] -
Delphi
# Wednesday, January 31, 2007
I had a requirement to make a list of objects be displayed in some kind of a grid metaphor. I've used the DataGridView before, and even written some blog entries on extending it (check out the cool Search feature on my blog for more information). However, all of my grid usage had been limited to database-related use.

What I needed was a way to easily get filtering and sorting working for the list of objects. I found 2 links that helped me out a ton. The first one is Building a Drop-Down Filter List for a DataGridView Column Header Cell. This article is incredibly well-written and talks about the different interfaces you need to implement, and provides a sample, too. For the sorting, I used Brian Noyes' BindingListView class from Chapter 9 of his excellent book, Data Binding with Windows Forms 2.0.

When stitching these 2 pieces together, I noticed several things:

  • The DataGridViewAutoFilterColumnHeaderCell.UpdateFilter method was adding square brackets around the property names for some reason. I can't tell why this was being done, but my guess is it had to do with spaces in database column names. Since I'm not using it for that purpose, I removed the brackets. The other approach would have been to adjust the BindingList.UpdateFilter method to deal with the brackets, so I may revisit this in the future.
  • The BindingListView.UpdateFilter needed some minor modifications. I added a precondition guard check to make sure m_FilterString is not null. It looks like the DataGridViewAutoFilterColumnHeaderCell class will call back to the BindingListView class more frequently than Brian had anticipated.
  • I adjusted the setter of the IBindingListView.Filter property to remove the filter if it gets set to String.Empty or null.

    string IBindingListView.Filter

    {

        get

        {

            return m_FilterString;

        }

        set

        {

            if (string.IsNullOrEmpty(value))

                ((IBindingListView)this).RemoveFilter();

            else

            {

                m_FilterString = value;

                m_Filtered = true;

                UpdateFilter();

            }

        }

    }

  • You need to build up your collection of objects using BindingListView
  • You must use a BindingSource to link between your collection and the DataGridView by setting dataGridView1.DataSource = myBindingSource.

By doing all of this, I got things working the way I wanted. Now it's time to tackle the next task of getting child objects bound properly in a DataGridView.

Wednesday, January 31, 2007 2:48:22 PM (Central Standard Time, UTC-06:00)  #    Comments [1] -
.NET
Navigation
Archive
<March 2007>
SunMonTueWedThuFriSat
25262728123
45678910
11121314151617
18192021222324
25262728293031
1234567
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Dan Miser
Sign In
Statistics
Total Posts: 375
This Year: 3
This Month: 0
This Week: 0
Comments: 654
Themes
Pick a theme:
All Content © 2012, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)