|
Recently I’ve moved to a new content management system (dasBlog).My old way of doing thing was to write my own blogging software and use that. Thesad fact is that I just didn’t have the time of patience to work out the bugs anddasBlog offered a lot more features. The only problem is that dasBlog stores entriesas XML text files and my old system stored them in a SQL Server database. Thus I neededa way to move hundred of entries out of SQL Server and into dasBlog formatted XML.My first thought was some type of fancy FOR XML query that would spit out the XMLand then I’d have to somehow parse that ginormous file into day-by-day XML files.Yeah, I went with that idea for about 5 minutes. All my searches turned up nothingspectacular (unless of course I was converting Radio UserLand to dasBlog) until Ifound Blobservations.So, thanks to Rick’scode I was able to import all my old posts from start to finish in under fortyminutes last night. I used pretty much the same logic, but wrote my script to accessmy database instead of a blogger exported XML file. Here’s the quick and dirty codeif you need to export blog entries from a database into dasBlog: Public Function ExportToDasBlog() As Integer
’setup local constants ‘if you’re copy and pasting this code, ‘ all you need to change are the constant values below Const exportDirectory As String = “C:\dasBlogContent” Const commandText As String = “SELECT * FROM MyTable with (nolock)” Const connectionString As String = “Data Source=www.myserver.com;” & _ “Initial Catalog=myDatabase;” & _ “User ID=myName;” & _ “Password=myPassword” Const author As String = “Jeffrey Kelso” Const contentFieldName As String = “Content” Const dateCreatedFieldName As String = “DateAdded” Const dateModifiedFieldName As String = “DateEdited” Const titleFieldName As String = “Subject” ‘create the service that will save the entries ‘build our command and open the connection ‘get a datareader of records to process ‘loop through the records and convert them to a dasBlog format entry = New newtelligence.DasBlog.Runtime.Entry entry.Author = author ‘use the dasBlogDataService to save the new object ‘increment our count End While ‘close the datareader, connection, and return End Function
|
Navigation
Search
My Photos
www.flickr.com
This is a Flickr badge showing photos in a set called
Weblog photos. Make your own badge
here.
|