Developing For .NET

Real World .NET Methods, Tricks, and Examples

Archive for the 'Miscellaneous' Category

Sun agrees to buy MySQL

OK, so I know this is not a .NET specific topic, but I thought this was important enough to share.  According to SitePoint.com, one of my favorite sites and publishers, Sun is buying MySQL for $1 Billion.  MySQL has been instrumental in the growth of Open Source, the acceptance of PHP, and the explosion of Internet interests such as blogs.  Without a stable, reliable, easy to use, free database, none of these things would have been nearly as successful or prolific as they have been.  For many, this represents a sell out by one of the corner stones of the Open Source movement.

Fortunately, according to the post above, Sun has a good track record of acquiring but not destroying Open Source technologies:

But there is other evidence of Sun understanding the value of keeping software open source and free: projects like OpenOffice.org and NetBeans have healthy communities and promising road maps. In fact, if you examine Sun’s current offerings to the corporate world, the only key component missing from the portfolio (and one that competitors such as Oracle, IBM, and Microsoft already offer) is a database. MySQL, with over 10 million installations worldwide (including high-traffic sites such as Google and Facebook) is a natural fit.

I have written here before about one of my first projects, a wrapper system for accessing multiple ADO.NET data sources.  MySQL was one of the initial databases that project supported (and still does today).  We use MySQL a lot for Internet applcations, so I will be watching this development with some interest.

2 comments

Saving Word 2007 Docs to PDF

This is not really a development issue, but something I found that might interest you.

With my new computer, I recently installed Office 2007 Enterprise (courtesy of our Microsoft Partner Action Pack) on my new Vista machine. I wanted to save a document to PDF, so I searched the help and it indicated that I could.

Unfortunately, the default install did not appear to be capable of doing so, but I found this document at Microsoft, which led me to another page: Enable support for other file formats, such as PDF and XPS. Turns out there is a free plug-in you can install that will enable additional file format support.

A quick Windows Validation, download, and install later and I am now saving docs to PDF. Just thought I would share, hope it helps someone out there.

No comments

Back from Vacation

Hey folks!  Just wanted to let you all know I’m back from vacation so I’ll be posting again soon.  I did spend the last hour or so upgrading Wordpress, so if you see any irregularities be sure to let me know.

On a more traditional note, let me wish you all a Happy New Year.  I’m not a big fan of New Year’s Resolutions, but this year I have a list I’d like to share.  And so, in Calendar year 2008, I resolve to:

  • Learn Blend, XAML, and WPF
  • Finally learn ASP.NET and publish an ASP.NET driven website
  • Take a SQL Server class
  • Publish a White Paper (already underway - watch for the announcement)
  • Post here at least once a week but more often as I am able
  • Attend VSLive! somewhere other than Texas!
  • Find and become an active member of some .NET forums

Naturally, I will be sharing my experiences and efforts with you.  I welcome any and all feedback on the site and its content, so please feel free to comment here about what you would like to see.

No comments

Don’t forget to close StreamWriter

In the midst of all my testing, learning, and blogging, my employer occasionally expects me to write a little code. As a result, I’ve spent most of this week being a productive employee, so you’ll have to wait a little while longer for the LINQ articles. In the meantime, I wanted to share a bone head problem I ran into while working on this new project.

The new project is fairly straight forward: read some data from a database, analyze it, look for inconsistencies, correct the inconsistencies, update the database, log the changes in a text file. OK, there’s more going on, but this is the general gist of things.

Having completed the difficult bits, namely recognizing and correcting “user input irregularities”, I moved on to the seemingly mindless task of writing the before and after information to a log file. How many times have we all done this:

StreamWriter file = File.CreateText(logFileName);
foreach (var item in collection)
{
    file.WriteLine("Some Text");
}

Simple, right? I ran a test and opened the text file and all appeared to be well. A few tests later, while viewing the results in Excel 2007, I noticed that the last line was cut off. Surely the problem could not be with Excel, I thought, so I looked at the raw text file, and the last line was cut off so many characters in from the left.

Naturally, all sorts of questions start flying through my head. Can an open StreamWriter only handle so many lines? Or could it be a limitation on number of bytes? Is there some system or program memory setting I’m not aware of? The code was so simple that it had to be something more

But alas, a little digging quickly led me to the answer: it was in fact my code. I failed to Close the StreamWriter, and so there were bytes that even though I had issued WriteLine(), had not yet been saved (or flushed) to the Text file.

I added Close() and sure enough all my data was written to the text file.

StreamWriter file = File.CreateText(logFileName);
foreach (var item in collection)
{
    file.WriteLine("Some Text");
}
// Close the StreamWriter to flush all the data to the file!
file.Close();

It’s good once in a while to run into something like this: it keeps us humble. Like the Roman Generals of old it reminds us that “we are mortal”.

Cheers, and Merry Christmas.

4 comments

Developing For .NET is a year old!

Well, it’s official: today marks the first anniversary of the first post here at developingfor.net.  One year ago today, a friend and former co-worker Jim Burnett wrote the first post about ini File Access with VB.NET.  Jim only wrote a few other posts before moving on to other projects, but he got the ball rolling.

Over the last year, there have been 53 posts, almost 7,000 unique visitors, and over 11,000 page views.  The average view numbers steadily climb every month.  Several of the posts are even frequently submitted to Digg.  What this tells me is that some readers out there like the site and are getting something out of it.  That was always the goal: to help others.

What I would like is to hear from you, the reader.  I’d like to know what you like, what you don’t like, and what you’d like to see.  Send requests for topics, samples, or code that you would like to see here on the site.

So thanks for making 2007 a great start: register today and post a comment, help me make this site even better in 2008.

– Joel Cochran

No comments

Site Update

Since I am stuck waiting for VS2008 to finish downloading (again - currently at 35%), I thought that I would address something that has bugged me here for a while. I’ve never liked the option employed for showing code on the site. It’s ugly and bulky and does not handle line breaks, indenting, or syntax highlighting. Here is an example of what it used to look like:

protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
lblIsFirstTime.Text = “This is the first call.”;
}
else
{
lblIsFirstTime.Text = “This is a PostBack”;
}
}

I hit the Google pavement today and found a Wordpress Plugin for Code Highlighting. It installed easily and I went to work right away replacing the old code wrappers with this one. Now the examples should look like this:

protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        lblIsFirstTime.Text = "This is the first call.";
    }
    else
    {
        lblIsFirstTime.Text = "This is a PostBack";
    }
}

I turned off line numbering, which is a plug-in wide setting, but I might fiddle with it to see if I can turn it on and off an runtime with an attribute. It would be handy for some examples to be able to reference line numbers. Also, I’d like to see if I can make it horizontally scrollable since some of the code wraps and isn’t as visually appealing (although it should copy and paste into your IDE just fine.)

I’ve gone back through all the old posts that show code and made this upgrade, so I hope you find them more usable now. Thanks to Dean Lee for a very useful plug-in.

UPDATE (94% downloaded):

I did correct the wrapping/scrollable issue mentioned above. This way, code actually looks as intended and preserves the original line break integrity.

I looked at the line number question also, but I do not see how I can make that change, at least not with some serious investigation, which I am not prepared to do. It functions well enough now as is. I also experimented with the color scheme, trying to make it closer to how Visual Studio highlights, but I actually like this way better. It has a few quirks though: for one, I cannot get “foreach” to color properly (even though it is in the Syntax array right next to “for”. I even tried reordering them in case it was a lookup bug, but no dice). There are a couple of other small items, but none of them detract from the code, so I’m not going to fuss with it anymore for now.

No comments

« Previous Page