I need to do this too, but I'm not using Sharepoint.
I've been doing it manually in Visual Studio - first publishing to my test web site then updating all the datasource URLs and re-publishing to the prod web site. This is tedious, especially since VS then creates new versions of all the xsd and xml files in the solution which causes grief with Source Safe.
Is there a better solution? I don't see where the code above would go...