
Tuesday, July 22, 2008
2010 Camaro
Yesterday Chevrolet revealed the production 2010 Camaro to the public. Video of the event can be seen here. I've been a long time fan of the Camaro
, and have had high expectations of the new model ever since the concept was released. Based on the information so far, it appears that the car is going to live up to my high hopes, and beyond. Looks like it's time to start making room in my garage for a new addition!
Thursday, July 3, 2008
Troubleshooting Datasets
Lately I have been working a lot with strongly typed datasets, and have found that they can be difficult to troubleshoot when faced with the dreaded error message:
"Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints."
After some research, I found a blog post by Roy Osherove where he had faced the same problem. In this post, Sanjay lists the following suggestion:
"Essentially, when I see the message above, I check the HasErrors property for each DataTable in the data set and then invoke the GetErrors method on the tables reporting errors. The GetErrors returns a collection of DataRows and you can invoke the .RowError property on the each of the error-stricken rows to find out just exactly what the problem is... "
His suggestion has made troubleshooting much easier. Just disable constraints on the dataset, and then write code to catch the problem once contraints are enabled. Here is a snippet of the version that I came up with:
"Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints."
After some research, I found a blog post by Roy Osherove where he had faced the same problem. In this post, Sanjay lists the following suggestion:
"Essentially, when I see the message above, I check the HasErrors property for each DataTable in the data set and then invoke the GetErrors method on the tables reporting errors. The GetErrors returns a collection of DataRows and you can invoke the .RowError property on the each of the error-stricken rows to find out just exactly what the problem is... "
His suggestion has made troubleshooting much easier. Just disable constraints on the dataset, and then write code to catch the problem once contraints are enabled. Here is a snippet of the version that I came up with:
try
{
this.EnforceConstraints = true;
}
catch
{
foreach(DataTable dt in this.Tables)
{
if (dt.HasErrors)
{
DataRow[] rowErrors = dt.GetErrors();
for (int i = 0; i < rowErrors.GetLength(0); i++)
{
System.Windows.Forms.MessageBox.Show(dt.TableName + ": " + rowErrors[i].RowError.ToString());
}
}
}
}
Tuesday, June 3, 2008
Disabling Word as Outlook's email editor
By default, Microsoft Outlook uses Word to edit email messages. This is a nice feature because it offers enhanced editing capabilities over the basic email editor. However, if you are using an under-powered machine like I had at my last employer, you really want to cut down on memory usage and don’t want Word running just so you can send a quick email. When this is the case, you can stop Outlook from using Word to edit emails, by opening Tools -> Options, clicking the “Mail Format” tab, and deselecting the option “Use Microsoft Office Word 2003 to edit e-mail messages”.
This isn’t a revolutionary tip, but it’s something that I hadn’t thought to look for and would have been very useful when I was stuck on an old machine.
Formatting my MP3 player
My current MP3 player is a SanDisk Sansa c250
. It’s not a fancy as some of the more expensive units, but overall it’s very nice unit for the price. Recently I needed to transfer 1GB of data between to pc’s and didn’t have a flash drive handy; so I just copied the data to my Sansa and used it for the transfer. This seemed like a good idea at the time, but when I tried to delete the data from the MP3 player, I was faced the the error message “Folder cannot be deleted because it is protected.”. After some experimenting, it looks like the Sansa will not let you delete a folder if it contains data. This wouldn’t be a big deal, except that the data I had transferred contained hundreds of folders. There was no way I was going to dig through all of these folders to delete the files. Being a developer, I decided to automate the process and write a .NET application that would traverse the folder structure of the unit, and delete all of the files.
I threw together a quick app, tested it on some other folders, and was off to the races (or so I thought). I attempted to select the folder on the device (using the .NET FolderBrowserDialog), and Windows Vista gave me the error message “The folder cannot be used”.
I had never tried to access a portable device programmatically, so I wasn’t sure what the cause might be. Google’ing didn’t help. Next, I did some debugging to find out what the referenced file path was so I could just hard code it. The path turned out to be in Temporary Internet Files. I’m not quite sure what this means, but obviously Windows doesn’t treat this device like a normal drive.
It was time to take a step back and think about what I was trying to accomplish. I wanted everything deleted from the device, except for my music. But, all my MP3’s are backed up on several devices. I took a quick look at the options on the Sansa, and it turns on there was a format device. This quickly wiped out everything, and then I simply copied the music back to the device.
I guess sometimes, it pays to approach a problem from a different perspective.
I threw together a quick app, tested it on some other folders, and was off to the races (or so I thought). I attempted to select the folder on the device (using the .NET FolderBrowserDialog), and Windows Vista gave me the error message “The folder cannot be used”.
I had never tried to access a portable device programmatically, so I wasn’t sure what the cause might be. Google’ing didn’t help. Next, I did some debugging to find out what the referenced file path was so I could just hard code it. The path turned out to be in Temporary Internet Files. I’m not quite sure what this means, but obviously Windows doesn’t treat this device like a normal drive.
It was time to take a step back and think about what I was trying to accomplish. I wanted everything deleted from the device, except for my music. But, all my MP3’s are backed up on several devices. I took a quick look at the options on the Sansa, and it turns on there was a format device. This quickly wiped out everything, and then I simply copied the music back to the device.I guess sometimes, it pays to approach a problem from a different perspective.
Thursday, May 22, 2008
Saving money on gas
Like a lot of people, I have a lengthy commute to work. As the price of gasoline continues to rise I have been thinking a lot about ways to save money on fuel. My wife and I have been carpooling to work, which means we can drive either her vehicle or mine. Hers is an SUV, and mine is something a little sportier. Mine gets better MPG, but runs on premium so it costs more to fill up. Neither one is cheap to drive, so we have thought about buying a third vehicle to be our work commuter. But, what would be the best option? We have considered buying a new compact, a new hybrid, a used sedan, or possibly buying a used diesel car and converting it to run on waste vegetable oil. Each of these choices has a wide variety of costs involved and offers different benefits. To weigh out the options, I put together an Excel spreadsheet that compares the cost of fuel for each vehicle, and how long it would take to recoup the costs of purchasing another vehicle. I thought spreadsheet might be helpful for others, so it is available for download here.

Just fill in the shaded cells with your vehicle choices, and compare the results. The other cells contain formulas that can be edited if you want to make the calculations based on different assumptions.
There are other expenses to consider such as insurance, and maintenance, but I think this is a good start.

Just fill in the shaded cells with your vehicle choices, and compare the results. The other cells contain formulas that can be edited if you want to make the calculations based on different assumptions.
There are other expenses to consider such as insurance, and maintenance, but I think this is a good start.
Monday, May 5, 2008
C# Code snippets
While making the transition from a VB.NET developer to C#, I noticed that there are far fewer out of the box code snippets for C# than VB.NET in Visual Studio 2005. A quick Google search for C# snippets revealed that Microsoft offers a separate download for C# snippets which matches all of the ones available for VB.NET. This was great news, but unfortunately the download link appears to be broken at the moment. I'm sure this will be fixed soon but in case it's not, Jeff Atwood has posted the snippets and helpful install info here.
Friday, May 2, 2008
New Job!
This week I started a new job with a software devlopment company (as opposed to the previous financial services company). This means that I will be working less with Microsft CRM, so there will be less blog posts about it, but I will continue to post information about other technologies. This week has been spent becoming more proficient in C# (instead of VB.NET which I had been focusing on) and learning about custom controls from Developer Express. There will be more posts once I get into the groove of the job.
Subscribe to:
Posts (Atom)