Your PHP installation appears to be missing the MySQL extension which is required by WordPress

I was recently setting up WordPress to run locally on my development machine and when I tried to browse to the WordPress homepage locally, I recieved the error:

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

My configuration:
Windowx XP
Apache 2.2
MySQL 5.1

To correct this issue, I did the following:

  1. In the Php.ini file (on my machine this is located at C:\Windows):
    Set extension_dir = "C:/Program Files/php-5.2.8/ext" (where php is installed on my machine)
  2. uncommented (remove ;)
  3. Copied libmysql.dll from php dir to system32 (C:\WINDOWS\system32 on my machine)

Hope that helps anyone with a similar issue.

ASP.NET error a control with id could not be located or a different control is assigned to the same ID after postback

Recently I came across an error in an page that took a fair amount of troubleshooting to resolve.  I had an page that was using a master page and within the aspx page, I had a grid view.  On the aspx page, I also had a drop down list that posted back to the server when the selected index changed.  On post back, I received the below error: 

An error has occurred because a control with id 'ctl00$ContentPlaceHolder1$gvFiles$ctl05$ctl00' could not be located or a different control is assigned to the same ID after postback. If the ID is not assigned, explicitly set the ID property of controls that raise postback events to avoid this error.


After some digging, I determined the error was due to multiple asp:ButtonField controls being placed in the GridView.  Since you can not assign an ID to these controls the above error was being raised.  I did not find out exactly why, but at a higher level, the issue was due to my master page having view state disabled.  Once I changed this so my master page had ViewStateEnabled="true" (I had previously set it to false) the error went away.  If you have viewstate turned off at the page or gridview level you may also encounter this issue.

Styling AJAX Control Toolkit Tab Control

If you have a need to apply custom styles to the AJAX Control Toolkit tab control you should take a look at Matt Berseth's post that includes examples.  You can also create your own do this, you can take a look at Matt's style sheets and then create your own from his. 

 In order to override the default styles, you will need to define the styles and then when you add the tab control, use the CssClass property to set the css style to use:

<ajaxToolkit:TabContainer runat="server" ID="Tabs" ActiveTabIndex="0" CssClass="ajax__tab_mycustom-theme">

Integrate Disqus into your site using JavaScript

Recently I added Disqus, a hosted comment system, to a site and wanted to point out a couple of things that were not too clear from the documentation on the Disqus site.  It may have been updated, but as of this post, I was not able to find too much info on the JavaScript implementaion of Disqus. 

Basically the JavaScript implementation will work with any web site technology, for example php, ASP.NET, etc.  In order to get it to work, you first need to sign up for an account.  Once you do this, they will provide you with the "code" that you need to add to your site.  Once you add this code, all of the necessary HTML and comment data will appear on your page. 

When you create an account, you provide your site URL. It is important to understand that if you are developing or testing your site on a server other than the one registered with your domain name, the Disqus comment section will not appear.  So if you are setting things up on your local machine and testing, you will not see the full comment section.  Once you push your code to production, you will then see the full Disqus comment section

That is is very easy to set up and use...

Create a comma seperated list from a column in a SQL Server table

Problem: you want to create a comma seperated list of values from a column in a database table.  You constraints are that you want to create the comma seperated list at the database level and you can not use a cursor or while loop.

For example, if you have a table called "Category" with a column "Name" that contains the values:


and you want to return Breakfast, Lunch, Dinner.

There are many ways to do this and most tend to involve looping or a pivot.  One efficient and elegant solution is to use a simple select statement:

declare @commaSeperatedNames varchar(max)
set @commaSeperatedNames = '';

select @commaSeperatedNames = @commaSeperatedNames + case
when len(@commaSeperatedNames) > 1 then ', '
else '' end
+ name from category;

select @commaSeperatedNames;

The key is to initialize the string var to an empty string so the concatenation works as expected. .

Server.Map path returns error System.InvalidOperationException: Failed to map the path in Cassini

I encountered an issue today while trying to use the Server.MapPath method in an web page.  When trying to use Server.MapPath with a virtual directory in IIS (outside the web site) I was receiving an System.InvalidOperationException: Failed to map the path error.  Turns out, since I was running the web site as a file system project, and using cassini, this error was being generated.  By moving the project to IIS and running the site under IIS and not cassini, the error went away.

Using Dependency Injection with an ObjectDataSource

In this post I will outline how to use dependency injection with an ObjectDataSource.  There are many benefits to using dependency injection and programming to interfaces including maintainability, extensibility, and testability.  For the example that follows the use case is to provide a pagable, sortable list of data, using a gridview, and performing the paging and sorting within the database for performance reasons.  Based on these requirements, an object data source is needed as it provides the mechanism to support custom paging and sorting for a grid view.

Dependency Injection For this example I have choosen StructureMap.  One of the nice features of StructureMap is that is allows you to map your Interfaces to concrete types using code.  The below code creates a Registry and leverages some new features in StrucutreMap version 2.5

public class ServiceRegistry : Registry
  protected override void configure()

This code instructs StructureMap to return PersonRepository when someone requests an IPersonService. There is a lot more you can do with StructureMap, for a complete overview of StructureMap, please check out their homepage.

Next, it is time to set up the ObjectDataSource.  An ObjectDataSource does not let you specify an Interface directly, so you need to override the default behavior.  First, define the types:

<asp:ObjectDataSource ID="ObjectDataSourcePerson" runat="server" SelectMethod="GetRecordList"        DataObjectTypeName="Services" TypeName=Services.IPersonService"        OnObjectCreating="ObjectDataSourcePerson_ObjectCreating" >   

The important things to note are the types (DataObjectTypeName is Namespace.Class, TypeName is Namespace.Class.Type) and the OnObjectCreating, this is where we will override the default behavior.  The code behind for this looks like: 

protected void ObjectDataSourcePerson_ObjectCreating(object sender, ObjectDataSourceEventArgs e)    {        
IPersonService personService =
e.ObjectInstance = personService;

Now, when the ObjectDataSource is created, the concrete type will be used.  The power here is that we did not have to specify the concrete type in the code or DataSource definition, so in the future we can change the implementation and not need to change the UI code.

From here, you can implement the paging and sorting in the custom type and wire it up to the ODS and GridView.


Software Development Podcasts

Below is a list of software development podcasts, IT Podcasts, and general computer related podcasts. Please add commnets on podcasts you enjoy...

.NET Rocks - This is a really good (quality and content) podcast that focuses on .NET development.  While the main focus is .NET there is a fair amount of content that applies to general computing and development such as design patterns, agilie practices, and more.

Software Engineerig Radio - This podcast provides an excellent variaty of topics that span technologies, languages, platforms, methodologies, etc. The shows can be rather technical and geared more toward knowledgable developers, but still offer a wealth of knowledge for beginners through experts.

Hansel Minutes - This is a weekly podcast that is primarily focused on Microsoft technologies but also includes other technologies and topics from time to time (for example digital photography).  While Scott is a Microsoft employee, the cast is rather open to non MS technologies and techniques such as TDD, ALT.NET, etc.

The Java Posse - This is an excellent podcast focused on the Java language, platform, and related technologies.  It provides both technical information as well as news and events within the Java community.

Buzz Out Loud - This is a daily podcast that is a summary of news and events relating to technology.  The personalities of the hosts really help to seperate this podcast from the usually news recap type shows...certainly worth checking out...

Polymorphic Podcast - A good podcast focusing on development and .NET.  The podcasts sometimes include screencasts and overall provides a lot of good content.

SSWUG - A database centric podcast dealing mainly with SQL Server but does include topics on other RBDMS as general database best practices.

Slashdot Review -  While at times biased, this can be a quick and informative cast.

Google Developer Podcast - Hopefully this will be a good resource to learn more about the technolgy offerings available through google.

Windows Weekly Podcast - Interesting take on the windows world.

ALT.NET Podcasts - A really good podcast that covers topics that all developrs should familiarize themselves with.

Deep Fried Bytes Podcast - Good podcast focusing on mainly Microsoft development

Thirsty Developer - Another good developer podcast focusing mainly on .NET - Good podcast relating to development

WebDevRadio - Covers web development

eCorner - Stanford entreprenure podcast 

Stackoverflow - development podcast 

ThoughtWorks - Business and technology topics

Agile Toolkit - topics relating to Agile development 

Udi Dahan - SOA podcast - New show hosted by Ron Jacobs on REST, SOA, web services, etc. - UI, UX, RIA info

Finacial Physician

Railscast - webcasts on Ruby on Rails

Rails Podcast - podcasts on RoR

FLOSS - Weekly podcast on free and open source software

GiaOM - weekly show about technology and business 

Pragmatic Programmers - Interesting tech podcasts

Rails Envy - Regular podcast on Ruby on Rails

The Start Up Success Podcast - Name says it all...

This Week in Start Ups - Podcast on business and technology

Mobil Orchard - iPhone development topics

Stuff You Should Know - Variety of interesting topics from science to general knowledge....quite entertaining....



Windows Server 2008 - Activation fails DNS name does not exist

I ran into an issue when trying to activate an Enterprise edition of Windows Server 2008.  I had installed the software from my MSDN account and when I tried to activate the software, I received a "DNS name does not exist" error.  To fix this problem, I had to re-enter the product key for the software.  After entering the product key (I just entered the key that was already entered from the install) I was then able to activate the software.

TableDiff tool for SQL Server

One of the nice tools that is provided with SQL Server 2005 is the TableDiff.exe table comparison tool.  It allows you to compare the data in the same table on different servers or instances.  Below is an expample that compares the data in "table1" and places the results in the table "Table1DifferencesServer1Server2".  This command needs to be run from the command line, in the directory where tablediff.exe is located.

C:\Program Files\Microsoft SQL Server\90\COM> tablediff -sourceserver "server1" -sourcedatabase "database1" -sourcetable "table1" -destinationserver "server2" -destinationdatabase "database1" -destinationtable "table1" -et Table1DifferencesServer1Server2

 More info can be found on BOL