<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cypris&#039; lookout &#187; Programming</title>
	<atom:link href="http://blog.nkadesign.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nkadesign.com</link>
	<description>Renaud Bompuis on the interwebs!</description>
	<lastBuildDate>Sat, 14 Jan 2012 06:30:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Programming podcasts</title>
		<link>http://blog.nkadesign.com/2011/programming-podcasts/</link>
		<comments>http://blog.nkadesign.com/2011/programming-podcasts/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 03:37:34 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[Musing]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=719</guid>
		<description><![CDATA[Podcasts are a great way to get educated and entertained. As a developer we are lucky to have a choice of some fine podcasts from industry leaders. If you commute, jog, travel, you can easily use that time away from the computer to get better informed and reflect about our field.]]></description>
			<content:encoded><![CDATA[<p>As a developer it&#8217;s often hard to stay current with your field. New technologies and new ways of doing programming pop up every day, it&#8217;s difficult to know if you should invest any time in learning them or if they are just passing fads.</p>

<p>Podcasts are a great way to get exposed to these new things: if you commute, jog, travel, you can easily use that time away from the computer to get better informed and reflect about our field.</p>

<p>I have a 20 minute walk between home and my office. That&#8217;s more than 3h of free time per week that I can spend thinking, listening to music or getting entertained and educated through relevant podcasts.</p>

<p>These are my preferred shows so far:</p>

<p><img src="/wp-content/uploads/2011/09/hanselminutes.jpg" alt="Hanselminutes podcast" title="Hanselminutes podcast" width="51" height="51" align="left" hspace="5" vspace="5" border="0" /> <strong><a href="http://www.hanselminutes.com/">Hanselminutes</a></strong> <a href="http://itunes.apple.com/us/podcast/hanselminutes/id117488860"><img src="/wp-content/uploads/2011/09/viewinitunes_enbws.png" alt="Subscribe with iTunes" /></a><br />
A 30 minute or so podcast about technologies, usually closely or distantly related to Microsoft development. Scott is an excellent interviewer and his <a href="http://www.hanselman.com/blog/">blog</a> is a must read too.</p>

<p><img src="/wp-content/uploads/2011/09/herdingcode.jpg" alt="Herding Code" title="Herding Code" width="51" height="51" align="left" hspace="5" vspace="5" border="0" /> <strong><a href="http://herdingcode.com/">Herding Code</a></strong> <a href="http://itunes.apple.com/podcast/herding-code/id284067914"><img src="/wp-content/uploads/2011/09/viewinitunes_enbws.png" alt="Subscribe with iTunes" /></a><br />
A 60 minute show with a bunch of well-known developers, <a href="http://odetocode.com/">K. Scott Allen</a>, <a href="http://weblogs.asp.net/kdente/">Kevin Dente</a>, <a href="http://lazycoder.com/weblog/">Scott Koon (Lazycoder)</a>, and <a href="http://weblogs.asp.net/jgalloway/">Jon Galloway</a> discussing wide-ranging topics with their guests.</p>

<p><img src="/wp-content/uploads/2011/09/dotnetrocks.jpg" alt=".Net Rocks!" title=".Net Rocks!" width="51" height="51" align="left" hspace="5" vspace="5" border="0" /><strong><a href="http://dotnetrocks.com/">.Net Rocks</a></strong> <a href="http://itunes.apple.com/podcast/.net-rocks!/id130068596"><img src="/wp-content/uploads/2011/09/viewinitunes_enbws.png" alt="Subscribe with iTunes" /></a><br />
The unavoidable 60 minute grand-father or all .Net podcasts. Funny and always informative. Also check out the related <a href="http://dnrtv.com/">DnrTV</a> for on-topic screencasts, excellent for getting started on a new technology.</p>

<p><img src="/wp-content/uploads/2011/09/polymorphic.jpg" alt="PolymorphicPodcast.com" title="PolymorphicPodcast.com" width="51" height="51" align="left" hspace="5" vspace="5" border="0" /><strong><a href="http://polymorphicpodcast.com/">The Polymorphic podcast</a></strong> <a href="http://itunes.apple.com/podcast/polymorphic-podcast/id73330909"><img src="/wp-content/uploads/2011/09/viewinitunes_enbws.png" alt="Subscribe with iTunes" /></a><br />
A nice podcast, the host, Craig Shoemaker, is a great inteviewer. Only drawback is that shows are not regularly produced.</p>

<p><img src="/wp-content/uploads/2011/09/stackexchange.jpg" alt="The Stack Exchange podcast" title="The Stack Exchange podcast podcast" width="51" height="51" align="left" hspace="5" vspace="5" border="0" /><strong><a href="http://blog.stackoverflow.com/category/podcasts/">The StackExchange podcast</a></strong> <a href="http://itunes.apple.com/us/podcast/the-stack-exchange-podcast/id279215411"><img src="/wp-content/uploads/2011/09/viewinitunes_enbws.png" alt="Subscribe with iTunes" /></a><br />
Sometimes random, mildly irritating at times (guests sound quality, audio sync between guest, ramblings about Stackoverflow&#8217;s principles) but usually both enlightenning and funny. Topics revolve around <a href="http://stackoverflow.com/">Stackoverflow</a> and the various <a href="http://stackexchange.com/sites">StackExchange</a> sites. It&#8217;s always worth listenting to <a href="http://www.joelonsoftware.com/">Joel Spolsky</a>, he tends to see clearly in an industry that often borders on the BS.</p>

<p><img src="/wp-content/uploads/2011/09/thisdeveoperslife.jpg" alt="This Developer's Life podcast" title="This Developer's Life podcast" width="51" height="51" align="left" hspace="5" vspace="5" border="0" /><strong><a href="http://www.thisdeveloperslife.com/">This Developer&#8217;s Life</a></strong> <a href="http://itunes.apple.com/us/podcast/this-developers-life/id389727545"><img src="/wp-content/uploads/2011/09/viewinitunes_enbws.png" alt="Subscribe with iTunes" /></a><br />
Last but not least, a beautifully produced podcast that covers more philosophical topics through interviews and real-life experiences. It&#8217;s not about technology, it&#8217;s about the human aspect of being a coder, and what it means to be one.</p>

<p>Whichever you choose, any of these podcasts are bound to expand your knowledge, educate and entertain you!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2011/programming-podcasts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Office 2010 SP1 and Access 2010 Runtime SP1 are broken</title>
		<link>http://blog.nkadesign.com/2011/office-2010-sp1-and-access-2010-runtime-sp1-are-broken/</link>
		<comments>http://blog.nkadesign.com/2011/office-2010-sp1-and-access-2010-runtime-sp1-are-broken/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 11:22:25 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MSAccess]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=706</guid>
		<description><![CDATA[(Updated Saturday 10DEC2011.) On 28th of June 2011, Microsoft Office 2010 Service Pack 1 and the Access 2010 Runtime Service Pack 1 were issued. After upgrading my development machine (Win7 x64) and a few clients (Windows 2008R2 x64) to SP1 (x86), I started to get strange issues: I use .Net libraries from my Access application [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/access.png" alt="Microsoft Access" title="Microsoft Access" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />  (<strong>Updated Saturday 10DEC2011.</strong>) On 28th of June 2011, Microsoft Office 2010 Service Pack 1 and the Access 2010 Runtime Service Pack 1 were issued.</p>

<p>After upgrading my development machine (Win7 x64) and a few clients (Windows 2008R2 x64) to SP1 (x86), I started to get strange issues:</p>

<ul>
<li>I use .Net libraries from my Access application and suddenly, even when not instantiating any .Net objects, Access would crash, usually on startup, but sometimes when opening the VBE.<br />
Decompiling and re-compacting the database would be OK, usually once, but the problem would reappear the next time I would restart the application.<br />
<center><img title="MSAccess error" src="/wp-content/uploads/2011/07/sshot-4.png" width=491 Height=128 style="float:center;margin:10px;" /></center></li>
<li>In the Runtime, I would get strange errors, such as <em>The setting your entered isn&#8217;t valid for this property</em>, or <em>Action Failed Error Number: 2950</em>, or <em>Runtime Error 3270 Property not found</em>.<br />
The strange thing about these errors is that they would occur in places that had not been modified for many releases of our application, parts that have been running without problem until now.<br />
<center><img title="MSAccess error" src="/wp-content/uploads/2011/07/sshot-5.png" width=327 Height=199 style="margin:10px;" /></center></li>
<li>Another weird issue was the systematic reset of our custom ribbon to its first tab. this could happen randomly, but most it could also be reproduced by simply opening a report as a tab page (that fill-in the whole MDI window). When closing that form, the first tab of the ribbon would select itself automatically. This wasn&#8217;t happening when closing pop-up windows.</li>
</ul>

<p>After removing the Office and Runtime Service Pack 1, everything went back to normal.</p>

<h3>A fix, finally!</h3>

<p>A good 6 months after SP1 was released, Microsoft finally issued <a href="http://support.microsoft.com/kb/2596585">hotfix</a> for the issue!<br />
So, <a href="http://answers.microsoft.com/en-us/office/forum/office_2010-access/access-2010-sp1-you-receive-random-crashes-in/d2bf6175-075a-4a12-a2b1-f55d40af271b?page=17">read about it on the MS Forums</a> and get your <a href="http://support.microsoft.com/kb/2596585">KB2596585</a> hotfix, then <a href="http://www.trigeminal.com/usenet/usenet004.asp">decompile</a> your database to clean it out.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2011/office-2010-sp1-and-access-2010-runtime-sp1-are-broken/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Access: checking blank variables</title>
		<link>http://blog.nkadesign.com/2009/access-checking-blank-variables/</link>
		<comments>http://blog.nkadesign.com/2009/access-checking-blank-variables/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 05:54:00 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MSAccess]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=618</guid>
		<description><![CDATA[I often have to test String, Variant or Object variables that have no content and could be considered &#8216;blank&#8217;. The problem is that testing for &#8220;blankness&#8221; can mean many different things to different types: For an Object type, the variable can be Nothing. For a String type, the string can have no content at all: [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/access.png" alt="Microsoft Access" title="Microsoft Access" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />
I often have to test String, Variant or Object variables that have no content and could be considered &#8216;blank&#8217;.</p>

<p>The problem is that testing for &#8220;blankness&#8221; can mean many different things to different types:</p>

<ul>
<li>For an <code>Object</code> type, the variable can be <code>Nothing</code>.</li>
<li>For a <code>String</code> type, the string can have no content at all: <code>""</code>, <code>vbNullString</code>.</li>
<li>For a <code>Variant</code> type, the string can have any of the following attributes or values:

<ul>
<li>it can be <code>Missing</code> if the variable is an unused optional parameter,</li>
<li>it can be <code>Empty</code> if it was never assigned,</li>
<li>it can be <code>Null</code> if, for instance it&#8217;s bound to a nullable field or unbound with no value,</li>
<li>it can be an empty string <code>""</code>, <code>vbNullString</code>.</li>
</ul></li>
</ul>

<p>When having to check these variables in code, it can be tiresome to have to go through testing some of these possibilities just to find out that your variable does or not not contains something useful, regardless of the type of variable you are using.</p>

<p>To avoid having to do all these tests, make the code a bit more tidy and allow me to move on to more important things, I use this small utility function quite often:</p>

<p><textarea name="code" class="vb:nogutter">
'-----------------------------------------------------------------------------
' True if the argument is Nothing, Null, Empty, Missing or an empty string .
'-----------------------------------------------------------------------------
Public Function IsBlank(arg As Variant) As Boolean
    Select Case VarType(arg)
        Case vbEmpty
            IsBlank = True
        Case vbNull
            IsBlank = True
        Case vbString
            IsBlank = (arg = vbNullString)
        Case vbObject
            IsBlank = (arg Is Nothing)
        Case Else
            IsBlank = IsMissing(arg)
    End Select
End Function
</textarea></p>

<p>So now I don&#8217;t have to worry so much about the type of the variable I&#8217;m testing when I want to know if it contains useful data:
<textarea name="code" class="vb:nogutter">
...
' Here assume that CustomerReference is a control on a form.
' By using IsBlank() we avoid having to test both for Null and empty string.
If IsBlank(CustomerReference) Then
   MsgBox "Customer Reference cannot be left blank."
End If
...
</textarea></p>

<p>Obviously, <code>IsBlank()</code> doesn&#8217;t replace the other tests but I found it to be more straightforward to use in most cases.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2009/access-checking-blank-variables/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Access: Run-time Error 3155 ODBC insert on a linked table failed</title>
		<link>http://blog.nkadesign.com/2009/access-run-time-error-3155-odbc-insert-on-a-linked-table-failed/</link>
		<comments>http://blog.nkadesign.com/2009/access-run-time-error-3155-odbc-insert-on-a-linked-table-failed/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 08:26:06 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MSAccess]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=606</guid>
		<description><![CDATA[I have been spending a lot of time trying to find out why some of the code used to insert new records into a linked SQL Server table would systematically fail with an error: Run-time Error '3155' ODBC--insert on a linked table failed It was driving me mad. I could insert a simple record using [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/access.png" alt="Microsoft Access" title="Microsoft Access" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />
I have been spending a lot of time trying to find out why some of the code used to insert new records into a linked SQL Server table would systematically fail with an error:</p>

<pre><code>Run-time Error '3155' ODBC--insert on a linked table  failed
</code></pre>

<p>It was driving me mad.<br />
I could insert a simple record using <em>SQL Server Management Studio</em>, I could add new records to the table in datasheet mode within Access, but as soon as I tried to insert a record from code, whether using DAO recordset or executing the same SQL INSERT, it would miserably fail.</p>

<p>After a fair bit of investigation and tests, of which you can read the full account on <a href="http://stackoverflow.com/questions/979269/inserting-null-in-an-nvarchar-fails-in-msaccess/">the question I asked on StackOverflow</a>, it turns out that this is a long-standing bug in the ODBC Driver (or Access).</p>

<p><code>Memo</code> fields in Access are usually translated into <code>nvarchar(MAX)</code> in SQL Server by tools like <a href="/2009/ms-access-upsizing-to-sql-server-2008/">SSMA</a>.<br />
Unfortunately, when you link tables having these fields using the <em>SQL Server Client</em> driver, these fields get incorrectly interpreted as <code>string</code>, even though they appear ok from the table design view.<br />
It&#8217;s only if you try to insert something into the field, either text larger than 255 chars or NULL, that you get the error message.</p>

<p>So, the solution, at least in this case, is to revert to the older <em>SQL Server</em> ODBC driver instead, or use <code>varchar()</code> instead of <code>nvarchar()</code>, but if you&#8217;re dealing with Unicode, you have to stick with <code>nvarchar()</code>.</p>

<h3>References</h3>

<ul>
<li>My question <a href="http://stackoverflow.com/questions/979269/inserting-null-in-an-nvarchar-fails-in-msaccess/">Inserting NULL in an nvarchar fails in MSAccess</a> on <a href="http://stackoverflow.com/">StackOverflow</a>.</li>
<li>A reference I found on this issue: <a href="http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/c6d2466e-ecb5-4a98-963f-ae827dbf8caa">Ms Access linking table with nvarchar(max)</a>.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2009/access-run-time-error-3155-odbc-insert-on-a-linked-table-failed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Access vs SQL Server: some stats (part 1)</title>
		<link>http://blog.nkadesign.com/2009/access-vs-sql-server-some-stats-part-1/</link>
		<comments>http://blog.nkadesign.com/2009/access-vs-sql-server-some-stats-part-1/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 04:00:53 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MSAccess]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=527</guid>
		<description><![CDATA[In the perspective of upsizing my current Access 2007 application, I have been trying to understand a bit more about the possible performance impact of various choices of Primary Keys. My problem is that currently, the Access application uses autoincrement numbers as surrogate Primary Keys (PK). Since I will need to synchronise the data over [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/access.png" alt="Microsoft Access" title="Microsoft Access" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />
In the perspective of upsizing my current Access 2007 application, I have been trying to understand a bit more about the possible performance impact of various choices of Primary Keys.</p>

<p>My problem is that currently, the Access application uses autoincrement numbers as surrogate Primary Keys (PK).
Since I will need to synchronise the data over multiple remote sites, including occasionally disconnected clients, I can&#8217;t use the current autoincrement PK and will need to change to GUID.</p>

<p>To see for myself what could be the impact, I made a series of benchmarks.<br />
This first part is fairly simple:</p>

<ul>
<li>Populate a Product table that contains 3 fields: <code>ID</code>, <code>SKU</code> and <code>Designation</code> with 1,000,000 records.</li>
<li>Test natively on SQL Server and Access 2007.</li>
<li>The records are inserted in transactions batches of 1000 records.</li>
<li>I collect the time taken for each of these transactions and plot it.</li>
</ul>

<h3>Test setup</h3>

<p>Nothing much to say about that:</p>

<blockquote>
  <p>All tests are performed on a dedicated <em>Windows Server 2008 x64</em> rack running <em>Access 2007</em> and <em>SQL Server 2008 Standard (SP1) x64</em>.</p>
</blockquote>

<h3>Test database</h3>

<p>In SQL Server, we created a database with two tables <code>ProductGUID</code> and <code>ProductInt</code>:</p>

<p><textarea name="code" class="sql:nogutter" cols="60" rows="10">
CREATE TABLE ProductGUID (
	ID UNIQUEIDENTIFIER DEFAULT NEWSEQUENTIALID(),
	SKU NVARCHAR(32) NOT NULL,
	Description NVARCHAR(255) NULL
);
CREATE CLUSTERED INDEX ProdGUIDix ON ProductGUID(ID);
GO

CREATE TABLE ProductINT (
	ID INT IDENTITY(1,1),
	SKU NVARCHAR(32) NOT NULL,
	Description NVARCHAR(255) NULL
);
CREATE CLUSTERED INDEX ProdINTix ON ProductINT(ID);
GO
</textarea></p>

<p>For the table using a GUID, we use the <code>NewSequentialID()</code> instead of <code>NewID()</code> to create new keys. This is supposed to offer much better performance as the generated GUIDs are guaranteed to be sequential rather than random, resulting in better index performance on insertion.</p>

<p>For the Access version of the tables, we basically use the same definition, except that we used 4 tables:</p>

<ul>
<li>ProductINT: let Jet/ACE autonumbering create the sequential integer Primary Key.</li>
<li>ProductINTRandom: let Jet/ACE autonumbering create the random integer Primary Key.</li>
<li>ProductGUIDRandom: let Jet/ACE use its own internal <code>GenGUID()</code> for the key which generates random GUIDs instead of sequential ones.  </li>
<li>ProdcutGUIDSequential: call the Windows API (<a href="http://www.pinvoke.net/default.aspx/rpcrt4/UuidCreateSequential.html">UuidCreateSequential</a>) to create sequential ID instead.</li>
</ul>

<h3>SQL Server Test code</h3>

<p>Using the SQL Server Management Studio, we performed the following test once for each table (resetting the database in-between):
<textarea name="code" class="sql:nogutter" cols="60" rows="10">
SET NOCOUNT ON;
GO

DECLARE @i INT = 1;
WHILE (@i <= 1000)
BEGIN
	DECLARE @tstart DATETIME2 = SYSDATETIME();
	BEGIN TRAN
		DECLARE @a INT = 1;
		WHILE (@a <= 1000)
		BEGIN
			INSERT INTO ProductGUID (SKU,Description) 
			VALUES ('PROD' + CONVERT(CHAR,@a), 'Product number ' + CONVERT(CHAR,@a));
			SELECT @a = @a + 1;
		END;
	COMMIT TRAN;
	SELECT DATEDIFF(MILLISECOND, @tstart, SYSDATETIME()) AS timespan;
SELECT @i = @i + 1;
END;
GO
</textarea></p>

<p>Basically, we perform 1000 transactions each inserting 1000 records into the table <code>ProductGUID</code> or <code>ProductINT</code>.</p>

<h3>Access 2007 Test code</h3>

<p>To duplicate the same conditions, the following VBA code will perform 1000 transactions each inserting 1000 records.<br />
Note that the recordset is opened in Append mode only.<br />
The importance of this will be discussed in another article.</p>

<p><textarea name="code" class="vb:nogutter" cols="60" rows="10">
' Run this to inset 1,000,000 products in batches of 1000
' In the given table
Public Sub Benchmark(TableName as String, InsertSeqGUID  as Boolean)
    Dim i As Integer
    For i = 1 To 1000
        Insert1000Products TableName, InsertSeqGUID 
    Next i
End Sub

' Insert 1000 products in a table
Public Sub Insert1000Products(TableName as String, InsertSeqGUID as boolean)
    Dim i As Long
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim ws As DAO.Workspace
    Dim starttime As Long
    Dim timespan As Long
    
    Set ws = DBEngine.Workspaces(0)
    DoEvents
    starttime = GetClock ' Get the current time in ms
    ws.BeginTrans
    Set db = CurrentDb
    Set rs = db.OpenRecordset(TableName, dbOpenDynaset, dbAppendOnly)
    With rs
        For i = 1 To 1000
            .AddNew
                If InsertSeqGUID Then !ID = "{guid {" & CreateStringUUIDSeq() & "}"
                !SKU = "PROD" & i
                !Description = "Product number " & i
            .Update
        Next i
    End With
    ws.CommitTrans
    rs.Close
    timespan = GetClock() - CDbl(starttime)
    Set rs = Nothing
    Set db = Nothing
    ' Print Elapsed time in milliseconds
    Debug.Print timespan
    DoEvents
End Sub
</textarea></p>

<p>We call this code to perform inserts on each of our Access tables:</p>

<ul>
<li>ProductINT table: we just insert data in the <code>ProductINT</code> table, letting Access create autonumber IDs.</li>
<li>ProductINTRandom table: we just insert data in the <code>ProductINTRandom</code> table, letting Access create random autonumber IDs.</li>
<li>ProductGUIDRandom table: we let Access create the Random GUID for the primary key.</li>
<li>ProductGUIDSequential: we use the Windows API to create a sequential ID that we insert ourselves.</li>
</ul>

<h3>Test results</h3>

<p>Without further ado, here are the raw results, showing the number of inserted record per second that we achieve for each test over the growing size of the database (here are only shown tests comapring Sequantial GUID and Autoincrement on SQL Server and Access, see next sections for the other results):</p>

<p><img src="/wp-content/uploads/2009/04/chart04.png" alt="Inserts per second" /></p>

<p>What we clearly see here is that performance when using autoincrement and Sequential GUID stays pretty much constant over the whole test.<br />
That&#8217;s good new as it means that using Sequential GUIDs do not degrade performance over time.</p>

<p>As a side note, in this particular test, Access offers much better raw performance than SQL Server. In more complex scenarios it&#8217;s very likely that Access&#8217; performance would degrade more than SQL Server, but it&#8217;s nice to see that Access isn&#8217;t a sloth.</p>

<h3>Using Sequential GUID vs Autoincrement in Access</h3>

<p>The results show that we do take a performance hit of about 30% when inserting Sequential GUID vs just using autonumbers.<br />
We&#8217;re still getting good results, but that&#8217;s something to keep in mind.</p>

<p>In terms of CPU consumption, here is what we get:</p>

<p><img src="/wp-content/uploads/2009/04/CPUAccess.png" alt="CPU load Access" /></p>

<p>Random PK, whether they are simple integer or GUID do consume substantially more CPU resources.</p>

<h3>Using Sequential GUID vs Identity in SQL Server</h3>

<p>Out-of-the box, SQL Server performs quite well and there is not much difference whether you&#8217;re using Sequential GUIDs or autoincrement PK.</p>

<p>There is however a surprising result: using Sequential GUIDs is actually slightly <em>faster</em> than using autoincrement!</p>

<p>There is obviously an explanation for this but I&#8217;m not sure what it is so please enlighten me :-)</p>

<p>CPU Consumption:</p>

<p><img src="/wp-content/uploads/2009/04/CPUSQLServer.png" alt="CPU load SQL Server" /></p>

<h3>Using Random GUID vs Sequential GUID vs Random Autonumber in Access</h3>

<p>So, what is the impact of choosing a Sequential GUID as opposed to letting Access create its own random GUIDs?</p>

<p><img src="/wp-content/uploads/2009/04/chart05.png" alt="Inserts per second Random GUID vs Sequential GUID in Access" /></p>

<p>It&#8217;s clear that random GUIDs have a substantial performance impact: their randomness basically messes up indexing, resulting in the database engine having to do a lot more work to re-index the data on each insertion.<br />
The good thing is that this degradation is pretty logarithmic so while it degrades over time, the overall performance remains pretty decent.<br />
While GUIDs are larger than Random Integers (16 bytes vs 4 bytes) the actual performance of inserting records whose PK is a random integrer is actually worse than random GUID&#8230;</p>

<h3>Provisional conclusions</h3>

<p>Here we&#8217;ve check the baseline for our performance tests.
In the next article, we&#8217;ll look exclusively at the performance of inserting data from a remote Access 2007 front end using our VBA code.</p>

<p>Having this baseline will allow us to check the performance overhead of using ODBC and letting Jet/ACE manage the dialogue with the SQL Server backend.</p>

<p>Feel free to leave your comments below, especially if you have any resources or information that would be useful.</p>

<h3>Updates</h3>

<ul>
<li>16APR2009: added test of random autonumber as PK in Access.</li>
<li>13APR2009: Original Article</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2009/access-vs-sql-server-some-stats-part-1/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Sysadmin: SQL server performance madness</title>
		<link>http://blog.nkadesign.com/2009/sysadmin-sql-server-performance-madness/</link>
		<comments>http://blog.nkadesign.com/2009/sysadmin-sql-server-performance-madness/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 11:25:56 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=550</guid>
		<description><![CDATA[I&#8217;ve just lost 2 days going completely bananas over a performance issue that I could not explain. I&#8217;ve got this Dell R300 rack server that runs Windows Server 2008 that I dedicate to running IIS and SQL Server 2008, mostly for development purposes. In my previous blog entry, I was trying some benchmark to compare [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/windows.png" alt="Technology" title="Technology" align="left" width="64" height="60" hspace="5" vspace="5" border="0" />
I&#8217;ve just lost 2 days going completely bananas over a performance issue that I could not explain.</p>

<p>I&#8217;ve got this <a href="http://www.dell.com/content/products/productdetails.aspx/pedge_r300?c=us&amp;cs=555&amp;l=en&amp;s=biz">Dell R300</a> rack server that runs Windows Server 2008 that I dedicate to running IIS and SQL Server 2008, mostly for development purposes.</p>

<p><img src="/wp-content/uploads/2009/04/pedge_r300_overview1.jpg" alt="Dell PowerEdge R300 Rack servers" /></p>

<p>In my <a href="/2009/access-vs-sql-server-some-stats-part-1/">previous blog entry</a>, I was trying some benchmark to compare the performance of Access and SQL Server using INT and GUID and getting some strange results.
<!--
To get a more accurate baseline to explain the results I was getting from the server, I've tried this little snippet of SQL (the test database is simply a table with a IDENTIY column `ID`, and two text columns `SKU`, and `Description`).  
<textarea name="code" class="sql:nogutter" cols="60" rows="10">
DECLARE @tstart DATETIME2 = SYSDATETIME();
-- BEGIN TRAN
	DECLARE @a INT = 1;
	WHILE (@a <= 1000)
	BEGIN
		INSERT INTO Product (SKU,Description) 
		VALUES ('PROD' + CONVERT(CHAR,@a), 'Product number ' + CONVERT(CHAR,@a));
		SELECT @a = @a + 1;
	END;
-- COMMIT TRAN;
SELECT DATEDIFF(MILLISECOND, @tstart, SYSDATETIME()) AS timespan;
</textarea>

OK, so now for the really weird thing that was driving me crazy.

I have SQL Server 2008 Standard installed on 3 different machines: the server, my desktop and my Macbook Pro.
--></p>

<p>Here are the results I was getting from inserting large amounts of data in SQL Server:</p>

<table border=1>
<thead>
<tr>
  <th>Machine</th>
  <th>Operating System</th>
  <th align="center">Test without Transaction</th>
  <th align="center">Test with Transaction</th>
</tr>
</thead>
<tbody>
<tr>
  <td>MacbookPro</td>
  <td>Windows Server 2008 x64</td>
  <td align="center">324 ms</td>
  <td align="center">22 ms</td>
</tr>
<tr>
  <td>Desktop</td>
  <td>Windows XP</td>
  <td align="center">172 ms</td>
  <td align="center">47 ms</td>
</tr>
<tr>
<td>Server</td>
  <td>Windows Server 2008 x64</td>
  <td align="center"><font color="red">8635 ms!!</font></td>
  <td align="center">27 ms</td>
</tr>
</tbody>
</table>

<p>On the server, not using transactions makes the query run more than 8 seconds, <strong>at least an order of magnitude slower than it should!</strong></p>

<p>I initially thought there was something wrong with my server setup but since I couldn&#8217;t find anything, I just spend the day re-installing the OS and SQL server, applying all patches and updates so the server is basically brand new, nothing else on the box, no other services, basically all the power is left for SQL Server&#8230;</p>

<h3>Despair</h3>

<p>When I saw the results for the first time after spending my Easter Sunday rebuilding the machine I felt dread and despair.<br />
The gods were being unfair, it had to be a hardware issue and it had to be related to either memory or hard disk, although I couldn&#8217;t understand really why but these were the only things that I could see have such an impact on performance.</p>

<p>I started to look in the hardware settings:</p>

<p><img src="/wp-content/uploads/2009/04/screen1.png" alt="Device Manager" /></p>

<p>And then I noticed this in the Policies tab of the <em>Disk Device Properties</em> :</p>

<p><img src="/wp-content/uploads/2009/04/screen2.png" alt="DISK Device Properties" /></p>

<p>Just for the <a href="http://encyclopediadramatica.com/Lulz">lulz</a> of it, I ticked the box, close the properties</p>

<p><img src="/wp-content/uploads/2009/04/screen3.png" alt="Enable advanced performance" /></p>

<p>And then tried my query again:</p>

<table border=1>
<thead>
<tr>
  <th>Machine</th>
  <th>Operating System</th>
  <th align="center">Test without Transaction</th>
  <th align="center">Test with Transaction</th>
</tr>
</thead>
<tbody>
<td>Server</td>
  <td>Windows Server 2008 x64</td>
  <td align="center"><font color="red">254 ms!!</font></td>
  <td align="center">27 ms</td>
</tr>
</tbody>
</table>

<p>A <strong>nearly 35 fold increase in performance!</strong></p>

<h3>Moral of the story</h3>

<p>If you are getting strange and inconsistent performance results from SQL Server, make sure you check that <em>Enable advanced performance</em> option.<br />
Even if you&#8217;re not getting strange results, you may not be aware of the issue, only that some operations may be much slower than they should.</p>

<p>Before taking your machine apart and re-installing everything on it, check your hardware settings, there may be options made available by the manufacturer or the OS that you&#8217;re not aware of&#8230;</p>

<p>Lesson learnt.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2009/sysadmin-sql-server-performance-madness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Access: building &#8216;upsizable&#8217; applications.</title>
		<link>http://blog.nkadesign.com/2009/access-building-upsizable-applications/</link>
		<comments>http://blog.nkadesign.com/2009/access-building-upsizable-applications/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 03:39:45 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MSAccess]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=433</guid>
		<description><![CDATA[When you start building an Access application, it&#8217;s tempting to just think about today&#8217;s problem and not worry at all about the future. If your application is successful, people will want more out of it and, over time, you&#8217;ll be faced with the task of moving the back-end database to a more robust system like [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/access.png" alt="Microsoft Access" title="Microsoft Access" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />
When you start building an Access application, it&#8217;s tempting to just think about today&#8217;s problem and not worry at all about the future.<br />
If your application is successful, people will want more out of it and, over time, you&#8217;ll be faced with the task of moving the back-end database to a more robust system like SQL Server.</p>

<p>While there are <a href="/2009/ms-access-upsizing-to-sql-server-2008/">tools like SSMA that can help you move an Access database to SQL Server</a>, <strong>a lot of the problems you&#8217;ll encounter can be solved before you even have to think about upsizing</strong>.<br />
Abiding by a few simple rules will cost you nothing when creating your Access application but will save you a lot of headache if -when- the time comes to upsize.</p>

<p>So here are a few things to keep in mind.</p>

<h3>Naming conventions</h3>

<p>Access is pretty liberal about naming conventions and it will let you freely name your tables, columns indexes and queries.
When these get moved to another database you&#8217;ll most probably be faced with having to rename them.<br />
In some cases, you could actually create subtle bugs because something that used to work fine in Access may be tolerated in the new database but be interpreted differently.</p>

<ul>
<li><p><strong>Do not use spaces or special characters</strong> in your data object names.<br />
Stick to characters in the range <code>A</code> through <code>Z</code>,  <code>0</code> to <code>9</code> with maybe underscores <code>_</code> somewhere in between (but not at the start or the end).<br />
Also try to respect casing wherever you reference this name (especially for databases like MySQL which are case-sensitive if the hosted on a Linux platform for instance).<br />
eg:<br />
<code>Customer Order Lines (archive)</code> should be  <code>CustomerOrderLines_Archive</code>.<br />
<code>Query for last Year's Turnover</code> should be <code>QueryLastYearTurnover</code>.<br />
Index <code>ID+OrderDate</code> should become instead <code>ID_OrderDate</code>.</p></li>
<li><p><strong>Do not use keywords that are reserved</strong> or might mean something else whether they are SQL keywords or functions names:<br />
A column called <code>Date</code> could be renamed <code>PurchaseDate</code> for instance.<br />
Similarly, <code>OrderBy</code> could be renamed <code>SortBy</code> or <code>PurchaseBy</code> instead, depending on the context of <em>Order</em>.<br />
Failing to do so may not generate errors but could result in weird and difficult to debug behaviour.</p></li>
<li><p><strong>Do not prefix tables with <code>Sys</code>, <code>USys</code>, <code>MSys</code> or a tilde <code>~</code>.</strong><br />
Access has its own internal system tables starting with these prefixes and it&#8217;s best to stay away from these.<br />
When a table is deleted, Access will often keep it around temporarily and it will have a tilde as its prefix.</p></li>
<li><p><strong>Do not prefix Queries with a tilde <code>~</code>.</strong><br />
Access use the tilde to prefix the hidden queries kept internally as recordsource for controls and forms.</p></li>
</ul>

<h3>Database design</h3>

<ul>
<li><p><strong>Always use Primary keys.</strong><br />
Always have a non-null primary key column in every table.<br />
All my tables have an autonumber column called <code>ID</code>.  Using an automatically generated column ID guarantees that each record in a table can be uniquely identified.<br />
It&#8217;s a painless way to ensure a minimum level of data integrity.</p></li>
<li><p><strong>Do not use complex multivalue columns.</strong><br />
Access 2007 introduced <a href="http://office.microsoft.com/en-us/access/HA012337221033.aspx">complex columns that can record multiple values</a>.<br />
They are in fact fields that return whole recordset objects instead of simple scalar values.  Of course, this being an Access 2007 only feature, it&#8217;s not compatible with any other database.
Just don&#8217;t use it, however tempting and convenient it might be.<br />
Instead use a table to record Many-To-Many relationships between 2 tables or use a simple lookup to record lists of choices in a text field itself if you&#8217;re only dealing with a very limited range of multivalues that do not change.</p></li>
<li><p><strong>Do not use the Hyperlink data type.</strong><br />
Another Access exclusive that isn&#8217;t available in other databases.</p></li>
<li><p><strong>Be careful about field lookups.</strong><br />
When you create Table columns, Access allows you to define lookup values from other tables or lists of values.<br />
If you <em>manually</em> input a list of values to be presented to the user, these won&#8217;t get transferred when upsizing to SQL Server.<br />
To avoid having to maintain these lookup lists all over your app, you could create small tables for them and use them as lookup instead; that way you only need to maintain a single list of lookup values.</p></li>
<li><p><strong>Be careful about your dates.</strong><br />
Access date range is much larger than SQL Server.<br />
This has 2 side-effects:<br />
1) if your software has to deal with dates outside the range, you&#8217;ll end-up with errors.<br />
2) if your users are entering dates manually, they could have made mistakes when entering the year (like 09 instead of 2009).<br />
Ensure that user-entered dates are valid for your application.</p></li>
</ul>

<h3>VBA</h3>

<p>While most of your code will work fine, there are a few traps that will bomb your application or result in  weird errors:</p>

<ul>
<li><p><strong>Always explicitly specify options when opening recordsets or executing SQL.</strong><br />
With SQL Server, the <code>dbSeeChange</code> is mandatory whenever you open a recordset for update.<br />
I recommend using <code>dbFailOnError</code> as well as it will ensure that the changes are rolled back if an error occurs.
<textarea name="code" class="vb:nogutter">
Dim rs as DAO.RecordSet
' Open for read/write
set rs = db.OpenRecordSet("Stock", dbOpenDynaset, dbSeechanges + dbFailOnError)
' Open for read only
set rs = db.OpenRecordSet("Stock", dbOpenSnapshot)
' Direct SQL execution
CurrentDB.Execute "INSERT INTO ...",  dbSeeChanges + dbFailOnError
</textarea></p></li>
<li><p><strong>Get the new autonumbered ID <em>after</em> updating the record.</strong><br />
In Access, autonumbered fields are set as soon as the record is added even if it hasn&#8217;t been saved yet.<br />
That doesn&#8217;t work for SQL Server as autonumbered IDs are only visible after the records have been saved.
<textarea name="code" class="vb:nogutter">
' Works for Access tables only
' We can get the new autonumber ID as soon as the record is inserted
rs.AddNew
mynewid = rs!ID
...
rs.Update

' Works for ODBC and Access tables alike
' We get the new autonumber ID after the record has been updated
rs.AddNew
...
rs.Update
rs.Move 0, rs.LastModified
mynewid = rs!ID
</textarea></p></li>
<li><p><strong>Never rely on the type of your primary key.</strong><br />
This is more of a recommendation but if you use an autonumbered ID as your primary key, don&#8217;t rely in your code or you queries on the fact that it is a <em>long integer</em>.<br />
This can become important if you ever need to upsize to a replicated database and need to transform your number IDs into GUID.<br />
Just use a Variant instead.</p></li>
</ul>

<h3>Parting thoughts</h3>

<p>These simple rules will not solve all your problems but they will certainly reduce the number of issues you&#8217;ll be faced with when upsizing you Access application.<br />
Using a tool like <a href="/2009/ms-access-upsizing-to-sql-server-2008/">SSMA</a> to upsize will then be fairly painless.</p>

<p>If you have other recommendations, please don&#8217;t hesitate to leave them in the comments, I&#8217;ll regularly update this article to included them.</p>

<h3>References</h3>

<ul>
<li>You will find lots of other bits of wisdom on this page: <a href="http://www.granite.ab.ca/access/sqlserverupsizing.htm">My random thoughts on SQL Server Upsizing from Microsoft Access</a> by Tony, from Granite Consulting.</li>
<li>Martin Green&#8217;s Office tips has a series of <a href="http://www.fontstuff.com/siteindex.htm#access">articles on Access to SQL Server migration</a>.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2009/access-building-upsizable-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MS Access: upsizing to SQL Server 2008</title>
		<link>http://blog.nkadesign.com/2009/ms-access-upsizing-to-sql-server-2008/</link>
		<comments>http://blog.nkadesign.com/2009/ms-access-upsizing-to-sql-server-2008/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 07:00:36 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MSAccess]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=285</guid>
		<description><![CDATA[I&#8217;m currently researching ways to move my main MS Access application from a simple local network client/backend setup to a global, multiple remote sites configuration using SQL Server. One of the challenges is to upsize the current MS Access 2007 backend database to SQL Server 2008. If you try it from Access itself using the [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/access.png" alt="Microsoft Access" title="Microsoft Access" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />
I&#8217;m currently researching ways to move my main MS Access application from a simple local network client/backend setup to a global, multiple remote sites configuration using SQL Server.</p>

<p>One of the challenges is to upsize the current MS Access 2007 backend database to SQL Server 2008.
If you try it from Access itself using the Upsizing Wizard, you may end up getting this error message:</p>

<blockquote>
  <p><em>The Upsizing Wizard only works with Microsoft SQL Server (Versions 6.50 SP5 or higher). Please log in to a SQL Server data source.</em></p>
  
  <p><img src="/wp-content/uploads/2009/01/UpsizingErrorsm.png" alt="The Upsizing Wizard only works with Microsoft SQL Server (Versions 6.50 SP5 or higher). Please log in to a SQL Server data source." /></p>
</blockquote>

<p>After spending some time fiddling around with SQL Server settings I couldn&#8217;t understand why I was still getting this error.<br />
Turns out that the upsizing wizard is apparently sensitive to the version of SQL Server you&#8217;re using and it doesn&#8217;t consider SQL Server v10 (2008) as being later than v6.50&#8230;</p>

<p>This issue is in fact a blessing.<br />
Microsoft provides a migration tool for upsizing MS Access database to SQL Server 2008 that&#8217;s orders of magnitude better than anything the basic wizard can do: the <a href="http://www.microsoft.com/sqlserver/2008/en/us/migration.aspx">SQL Migration Assistant for Access, or SSMA</a>.</p>

<p>SSMA lets you take a bunch of Access databases and move the tables and queries you choose to SQL Server, automatically linking them in your original database if you want.<br />
It&#8217;s not just a one-off thing either: SSMA keeps track of the objects that where transferred and allows you to synchronise both schema and data as often as you need.</p>

<p>So here you are: do <strong>not</strong> use the basic <em>MS Access Upsizing Wizard</em>, download and use SSMA instead.</p>

<h3>Strange COM Error</h3>

<p>While SSMA works perfectly fine on my Windows 2008 x64 laptop, on my main Windows XP desktop it throws an exception when trying to load an Access database:</p>

<blockquote>
  <p><em>Unable to cast COM object of type &#8216;Microsoft.Office.Interop.Access.Dao.DBEngineClass&#8217; to interface type &#8216;Microsoft.Office.Interop.Access.Dao._DBEngine&#8217;<br />
  &#8230; {00000021-0000-0010-8000-00AA006D2EA4}&#8230;</em></p>
</blockquote>

<p>It was a COM error saying that the library for DAO couldn&#8217;t be loaded.</p>

<p><a title="Disabling Filesystem Compression" style="border:0;" href="/wp-content/uploads/2009/01/sshot-568.png" rel="lightbox"><img title="Disabling Filesystem Compression" src="/wp-content/uploads/2009/01/sshot-568sm.png" style="float:right;margin-left:10px;margin-bottom:5px;" /></a>
I couldn&#8217;t find any relevant information on the web.<br />
After a while, I had a look at the DAO driver in<br />
<code>C:\Program Files\Common Files\Microsoft Shared\DAO\dao360.dll</code><br />
and I noticed that the filename was in blue: that reminded me that I had set compression on the filesystem.</p>

<p>I disabled compression for the file and, magically, SSMA worked again&#8230;</p>

<p>Moral of the story: be careful about compressing your filesystem, some registered libraries and system files may work in unpredictable ways&#8230;</p>

<h3>References</h3>

<ul>
<li><a href="http://www.microsoft.com/sqlserver/2008/en/us/migration.aspx">SQL Server Migration Assistant for Access</a> main page.</li>
<li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=133B59C2-C89C-4641-BEBB-6D04476EC1BA&amp;displaylang=en">SQL Server Migration Assistant download</a>. Note that you will have to register to get a license file that you need to save on your PC before you can use this free tool.</li>
<li><a href="http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.access.sqlupsizing&amp;tid=a1198438-f914-4710-91ca-440da168dc5d&amp;cat=&amp;lang=&amp;cr=&amp;sloc=&amp;p=1">&#8220;Access 2007 Upsizing to SQL Server 2008 Express in SQL Upsizing&#8221;</a> discussion on Microsoft groups.</li>
<li><a href="http://support.microsoft.com/kb/838594">&#8220;KB838594: Error message when you try to upsize your Access database by using the Upsizing Wizard&#8221;</a> is not the problem here, but some may find the reference useful if you&#8217;re trying to upsize your MS Access database to a SQL Server database on a network.</li>
<li><a href="http://www.granite.ab.ca/access/sqlserverupsizing.htm">My random thoughts on SQL Server Upsizing from Microsoft Access</a> from Tony&#8217;s Access MVP website, and his <a href="http://www.granite.ab.ca/access/sqlserverupsizinglinks.htm">list of links to other resources</a>.</li>
</ul>

<h3>Updates</h3>

<ul>
<li>17MAR2009: Added section on the strange COM error.</li>
<li>14MAR2009 : Added links to Tony&#8217;s Access MVP website.</li>
<li>05JAN2009 : Original publication.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2009/ms-access-upsizing-to-sql-server-2008/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>.Net: Working with OpenOffice 3</title>
		<link>http://blog.nkadesign.com/2008/net-working-with-openoffice-3/</link>
		<comments>http://blog.nkadesign.com/2008/net-working-with-openoffice-3/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 20:06:27 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[OpenOffice]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=245</guid>
		<description><![CDATA[(Updated Wednesday 30JAN2009.) Developing applications that manipulate OpenOffice documents has always been rather tricky; not very difficult, but just tricky to get right. With OpenOffice 3, things got trickier and applications that used to work will now fail. I&#8217;ve just spend nearly a day trying to get a mail-merge application I built to work again [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/technology02.png" alt="technology02.png" title="technology02.png" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />(<strong>Updated Wednesday 30JAN2009.</strong>) Developing applications that manipulate OpenOffice documents has always been rather tricky; not very difficult, but just tricky to get right.</p>

<p>With OpenOffice 3, things got trickier and applications that used to work will now fail.
I&#8217;ve just spend nearly a day trying to get a mail-merge application I built to work again with the new version of OO.<br />
<a href="http://www.openoffice.org"><img src='/wp-content/uploads/2008/11/ooo3.png' alt='OOo3'  style="float:right;margin-left:10px;margin-bottom:5px" border=0 width=250 height=162/></a></p>

<h3>Changes and limitations</h3>

<p>Developing .Net applications with OpenOffice 3 <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/CLI/CLI_Language_Binding">now requires that the .Net framework 3.5 be installed</a>.<br />
Only one version of OpenOffice/StarOffice must be installed.</p>

<h3>Getting the CLI assemblies in your project</h3>

<p>OpenOffice used to ship with a bunch of CLI DLLs for manipulating Open Documents from .Net.
With OpenOffice version 3, these DLLs are directly installed in the GAC and not available in the Program installation folder any longer, making them unavailable when you need to add them as references to your Visual Studio project.</p>

<p>The trick is to extract the DLLs from the installation CAB, then reference those and make sure you exclude them in your setup file so only the latest version installed on the user&#8217;s computer&#8217;s GAC will get used.</p>

<ol>
<li>Open the installation folder where the installation files are extracted (usually left on your desktop under a folder like <code>OpenOffice.org 3.0 (en-US) Installation Files</code> during the OO installation process.</li>
<li>Open the <code>openofficeorg1.cab</code> file (using a utility like <a href="http://www.7-zip.org/">7zip</a> if necessary) and extract the files matching <code>cli_*.dl</code>.  </li>
<li>Add the ones you need to your VS Project&#8217;s references and make sure the properties of these references have their <em>Copy Local</em> and <em>Specific Version</em> properties set to <em>false</em>.</li>
<li>If you have a setup project that added these references to the list of files, right-click each of them and select <em>Exclude</em> to make sure they won&#8217;t be packaged.</li>
</ol>

<p>The reason for not deploying the DLLs is that they are very specific to a given OpenOffice version and the latest assemblies relevant to the user&#8217;s OpenOffice installation will already be deployed to the target machine&#8217;s GAC.<br />
When .Net loads assemblies, if they are not included in the path of the application being launched, they will be loaded from the GAC if they can be found there.</p>

<h3>Path and environment setup</h3>

<p>Before being able to call OpenOffice from your application you now must set your application&#8217;s environment variables to the correct paths so the assemblies can find the actual OpenOffice library and program files.</p>

<p>Basically, you need to add to your <code>PATH</code> the path to the folder where the UNO java libraries reside.
You also need to add a <code>UNO_PATH</code> environment variable that points to the program folder of OpenOffice.
Basically, before any call to OpenOffice functions you must:</p>

<ul>
<li>Append to <code>PATH</code> something like <code>C:\Program Files\OpenOffice.org 3\URE\bin</code>.</li>
<li>Create a <code>UNO_PATH</code> variable set to <code>C:\Program Files\OpenOffice.org 3\program</code>.</li>
</ul>

<p>Because there is no guarantee that these paths will not change or are valid for all systems you must get them from specific keys located in the Registry:</p>

<ul>
<li><code>PATH</code> is appended with the vaue of <code>HKLM\SOFTWARE\OpenOffice.org\Layers\URE\1\UREINSTALLLOCATION</code> to which you must append the <code>bin</code> directory.</li>
<li><code>UNO_PATH</code> is set to the content of the <code>HKLM\SOFTWARE\OpenOffice.org\UNO\InstallPath</code> key.</li>
</ul>

<p>See the C# and VB.Net code below for working examples.</p>

<h3>Special Considerations for x64 systems</h3>

<p>My development machine runs Windows Server 2008 x64 and I&#8217;ve ran into some specific issues that you&#8217;re likely to encounter when deploying to a 64 bits OS.</p>

<p><strong>OpenOffice is 32 bits only</strong><br />
That means that your .Net project must be set to target x86 systems only:<br />
Open your Solution&#8217;s <em>Configuration Manager</em> and under <em>Active solution platform</em> click <em>New&#8230;</em> then:</p>

<p><center><img src="/wp-content/uploads/2008/11/sshot-4.png" alt="Configuration" /></center></p>

<p>Make sure you repeat this for both the <em>Debug</em> and <em>Release</em> configurations.</p>

<p><strong>Registry keys are elsewhere</strong><br />
32 bit applications see their registry keys normally expected under:<br />
<code>HKEY_LOCAL_MACHINE\Software</code> moved to:<br />
<code>HKEY_LOCAL_MACHINE\Software\Wow6432Node</code> instead.<br />
This of course creates issues when you&#8217;re trying to read a registry key that&#8217;s not where it should be&#8230;</p>

<h3>The Code</h3>

<p>The code below will allow you to correctly connect to OpenOffice 3 under 32 or 64 bit systems.<br />
It reads the registry to find the proper paths and appends the <code>PATH</code> and creates the <code>UNO_PATH</code> environment variables expected by the the bootstrapper to find the OpenOffice program and libraries.</p>

<p>The code is built upon information and a test program made available by <a href="http://www.schrievkrom.de/blog/">Marten Feldtmann</a> on his <a href="http://www.schrievkrom.de/blog/?p=199">blog</a> (more information, in English, is available on <a href="http://www.oooforum.org/forum/viewtopic.phtml?p=302441">OOoForum</a> ).</p>

<p>Please let me know if this works for you or if you have any corrections.
<textarea name="code" class="c#:nogutter" cols="60" rows="10">
private void InitOpenOfficeEnvironment() {
  string baseKey;
  // OpenOffice being a 32 bit app, its registry location is different in a 64 bit OS
  if (Marshal.SizeOf(typeof(IntPtr)) == 8)
      baseKey = @"SOFTWARE\Wow6432Node\OpenOffice.org\";	
  else
      baseKey = @"SOFTWARE\OpenOffice.org\";  

  // Get the URE directory
  string key = baseKey + @"Layers\URE\1";
  RegistryKey reg = Registry.CurrentUser.OpenSubKey(key);
  if (reg==null) reg = Registry.LocalMachine.OpenSubKey(key);
  string urePath = reg.GetValue("UREINSTALLLOCATION") as string;
  reg.Close();
  urePath = Path.Combine(urePath, "bin");

  // Get the UNO Path
  key = baseKey + @"UNO\InstallPath";
  reg = Registry.CurrentUser.OpenSubKey(key);
  if (reg==null) reg = Registry.LocalMachine.OpenSubKey(key);
  string unoPath = reg.GetValue(null) as string;
  reg.Close();

  string path;
  path = string.Format ("{0};{1}", System.Environment.GetEnvironmentVariable("PATH"), urePath);
  System.Environment.SetEnvironmentVariable("PATH", path);
  System.Environment.SetEnvironmentVariable("UNO_PATH", unoPath);
}
</textarea></p>

<p>In VB.Net:
<textarea name="code" class="vb:nogutter" cols="60" rows="10">
Private Sub InitOpenOfficeEnvironment()
  Dim baseKey As String
  ' OpenOffice being a 32 bit app, its registry location is different in a 64 bit OS
  If (Marshal.SizeOf(GetType(IntPtr)) = 8) Then
    baseKey = "SOFTWARE\Wow6432Node\OpenOffice.org\"
  Else
    baseKey = "SOFTWARE\OpenOffice.org\"
  End If

  ' Get the URE directory
  Dim key As String = (baseKey + "Layers\URE\1")
  Dim reg As RegistryKey = Microsoft.Win32.egistry.CurrentUser.OpenSubKey(key)
  If (reg Is Nothing) Then
    reg = Registry.LocalMachine.OpenSubKey(key)
  End If
  Dim urePath As String = CType(reg.GetValue("UREINSTALLLOCATION"),String)
  reg.Close
  urePath = Path.Combine(urePath, "bin")

  ' Get the UNO Path
  key = (baseKey + "UNO\InstallPath")
  reg = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(key)
  If (reg Is Nothing) Then
    reg = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(key)
  End If
  Dim unoPath As String = CType(reg.GetValue(Nothing),String)
  reg.Close

  Dim path As String
  path = String.Format ("{0};{1}",System.Environment.GetEnvironmentVariable("PATH"),urePath)
  System.Environment.SetEnvironmentVariable("PATH", path)
  System.Environment.SetEnvironmentVariable("UNO_PATH", unoPath)
End Sub
</textarea></p>

<h3>Updates</h3>

<p>07MAY2009 -- Added reference link to OOo documentation.<br />
03DEC2008 -- Added VB.Net translation. Thanks to Stefan for suggesting it.<br />
30JAN2009 -- Added reference to Aleksandr Sazonov&#8217;s article on CodeProject (thanks for the the article).</p>

<h3>References</h3>

<ul>
<li><a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/CLI/CLI_Language_Binding">CLI Language Binding</a></li>
<li><a href="http://www.oooforum.org/forum/viewtopic.phtml?t=76356&amp;start=0&amp;postdays=0&amp;postorder=asc&amp;highlight=">OOoForum thread</a> on getting sample C# code to work with OpenOffice 3</li>
<li><a href="http://www.oooforum.org/forum/viewtopic.phtml?p=302441">OOoForum thread</a> on upgrading code from OpenOffice 2.4 to 3</li>
<li><a href="http://opendocument4all.com/content/view/68/47/">Programming with .Net quick start guide</a>.</li>
<li><a href="http://www.oooforum.org/forum/viewtopic.phtml?p=302441">CLI UNO bridge not working</a></li>
<li><a href="http://www.codeproject.com/KB/cs/TblProc.aspx">Cross-compatible spreadsheet processor</a> in .Net for Excel and OOo Calc, article from Aleksandr Sazonov on CodeProject.</li>
<li><a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/CLI/Writing_Client_Programs">Writing client programs -- from the OOo documentation</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2008/net-working-with-openoffice-3/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Windows 2008 / Windows 7 x64: The &#8216;Microsoft.Jet.OLEDB.4.0&#8242; provider is not registered on the local machine.</title>
		<link>http://blog.nkadesign.com/2008/windows-2008-the-microsoftjetoledb40-provider-is-not-registered-on-the-local-machine/</link>
		<comments>http://blog.nkadesign.com/2008/windows-2008-the-microsoftjetoledb40-provider-is-not-registered-on-the-local-machine/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 13:31:53 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=236</guid>
		<description><![CDATA[There are times when the coexistence of 64 and 32 bit code on the same machine can cause all sorts of seemingly strange issues. One of them just occurred to me while trying to run the ASPx demos from Developer Express, my main provider of .Net components (the best supplier I&#8217;ve ever been able to [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/technology01.png" alt="Technology" title="Technology" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />There are times when the coexistence of 64 and 32 bit code on the same machine can cause all sorts of seemingly strange issues.<br />
One of them just occurred to me while trying to run the <a href="http://www.devexpress.com/Downloads/NET/OnlineDemos.xml">ASPx demos</a> from <a href="http://www.devexpress.com/">Developer Express</a>, my main provider of .Net components (the best supplier I&#8217;ve ever been able to find).<br />
I was getting the following error:</p>

<p><em>The &#8216;Microsoft.Jet.OLEDB.4.0&#8242; provider is not registered on the local machine:</em> 
<center><img src="/wp-content/uploads/2008/10/sshot-2.png" alt="Server Error" /></center></p>

<p>It may look otherwise, but this error is generally due to either of two thing:</p>

<ul>
<li>you don&#8217;t have Office 2007/2010 Jet drivers installed</li>
<li>or you are running a 32 bit application in a default x64 environment.</li>
</ul>

<p>The first issue is easy to solve, just download the <a href="http://www.microsoft.com/download/en/details.aspx?id=13255">Access 2010 Database Engine</a> from Microsoft (works with Access 2007 databases as well).</p>

<p>For the second one, the fix is also easy enough:</p>

<ul>
<li><em>For Windows 2008</em>: Navigate to  Server Manager > Roles > Web Server (IIS)  > Internet Information Services (IIS) Manager,  then look under your machine name > Application Pool.</li>
<li><em>For Windows 7</em>: Navigate to  Programs > Administrative Tools > Internet Information Services (IIS) Manager,  then look under your machine name > Application Pool.</li>
</ul>

<p><center><a title="Server Manager" style="border:0;" href="/wp-content/uploads/2008/10/sshot-6.png" rel="lightbox"><img title="Server Manager" src="/wp-content/uploads/2008/10/sshot-6sm.png" width=560 Height=410 /></a></center></p>

<p>Under there you can call the DefaultAppPool&#8217;s advanced settings to change <code>Enable 32-Bits Applications</code> to <code>True</code>:<br />
<center><img src="/wp-content/uploads/2008/10/sshot-3.png" alt="Advanced Settings" /></center></p>

<p>You may have to restart the service for it to take effect but it should work.</p>

<h3>References</h3>

<ul>
<li><a href="http://www.hanselman.com/blog/BackToBasics32bitAnd64bitConfusionAroundX86AndX64AndTheNETFrameworkAndCLR.aspx">Scott Hanselman&#8217;s blog entry</a> about undestanding 64 vs. 32 bitness in .Net.</li>
<li><a href="http://www.microsoft.com/download/en/details.aspx?id=13255">Access 2010 Database Engine driver</a></li>
</ul>

<h3>Updates</h3>

<ul>
<li>10DEC2011: Updated driver link to use the Access 2010 engine.</li>
<li>03APR2010: Added instructions for Windows 7</li>
<li>12FEB2009: Added reference to Scott&#8217;s article.</li>
<li>28OCT2008: Original version</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2008/windows-2008-the-microsoftjetoledb40-provider-is-not-registered-on-the-local-machine/feed/</wfw:commentRss>
		<slash:comments>73</slash:comments>
		</item>
		<item>
		<title>SysAdmin: Installing Windows Server 2008 x64 on a Macbook Pro</title>
		<link>http://blog.nkadesign.com/2008/mac-installing-windows-server-2008-x64-on-a-macbook-pro/</link>
		<comments>http://blog.nkadesign.com/2008/mac-installing-windows-server-2008-x64-on-a-macbook-pro/#comments</comments>
		<pubDate>Sun, 31 Aug 2008 06:04:39 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[MSAccess]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=149</guid>
		<description><![CDATA[My trusty old gigantic Sony Vaio is about 4 years old. It served me well and still works but it&#8217;s about to become my main development machine for the next couple of months and I can&#8217;t afford to have it die on me during that time. It was time to get something as gigantic and [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/apple.png" alt="security01.png" title="security01.png" align="left" width="53" height="64" hspace="5" vspace="5" border="0" />My trusty old gigantic <a href="http://etc.nkadesign.com/Linux/SonyVaio">Sony Vaio</a> is about 4 years old. It served me well and still works but it&#8217;s about to become my main development machine for the next couple of months and I can&#8217;t afford to have it die on me during that time.<br />
It was time to get something as gigantic and more up-to-date in terms of technology.</p>

<p>I use VMware on my main desktop to keep multiple OS setups that match typical configurations of my customer&#8217;s machines.<br />
This allows me to test my software before deployment and make sure everything works as expected.
It saved me many times from strange bugs and I would consider these final tests to be a mandatory step before deployment.<br />
My old trusty vaio would be hard pressed to run any of these without slowing down to a crawl.</p>

<p>I looked at some possible replacements. Initially I checked Lenovo&#8217;s offerings but they don&#8217;t seem to offer anything in large screen size (<a href="http://en.wikipedia.org/wiki/WUXGA">WUXGA</a> 1920&#215;1200) (Note, actually, <a href="http://www.tomshardware.com/news/Lenovo-W700-wacom-17-thinkpad,6117.html">they have</a>, but not really for me).<br />
Dito for Dell, not counting their humongous <a href="http://www.dell.com/content/products/productdetails.aspx/xpsnb_m1730?c=us&amp;l=en&amp;s=dhs">XPS M1730</a> luggable gaming machine that was wayyy over the top as a work computer, not to mention probably heavier than its volume in pure gold.</p>

<p><a title="Powerbook Pro" style="border:0;" href="/wp-content/uploads/images/MacBookPro_cr.png" rel="lightbox"><img title="Macbook Pro" src="/wp-content/uploads/images/MacBookPro_sm.png" width=250 Height=163 style="float:right;margin-left:10px;margin-bottom:5px;" /></a>
On a hint from a friend I checked out <a href="http://store.apple.com/hk/configure/MB166ZP/A?mco=NzUzNDY0">Apple&#8217;s online store</a> and saw they had a nice Macbook Pro configuration. I went to check it out in the retail store close to my office and they had that exact specification in stock, so, in what must have been the highest rated expense/time-to-think ratio of any decision I ever took, well, I bought it&#8230;</p>

<p>The spec, some bragging rights:</p>

<ul>
<li>Macbook Pro 17&#8243;</li>
<li>Core Duo T9500 2.6GHz processor</li>
<li>nVidia 8600M GT 512MB graphics card</li>
<li>200GB 7200rpm drive</li>
<li>Kingston 4GB DDR2 667MHz RAM</li>
<li>Hi Resolution 17&#8243; 1920&#215;1200 glossy screen</li>
</ul>

<p>It&#8217;s a <em>very</em> nice machine, Apple knows how to make nice hardware, there is no question there.<br />
OSX has some cool features, some of them still a bit foreign to me and some minor annoyances are creeping up, like Thunderbird&#8217;s not picking up my system date and time settings and displaying the date in the wrong format (a <a href="http://blog.nkadesign.com/2007/people-mind-your-dates-plz/">pet peeve</a> of me), probably not Apple&#8217;s fault but annoying nonetheless.<br />
So far so good and while I don&#8217;t mind using OSX for my browsing, email and creative stuff, that machine is meant to be running Windows Server 2008 x64 as a development platform.</p>

<h3>Why Windows Server 2008 x64?</h3>

<p>Well, it has some excellent features, a smaller footprint than Vista, all the aero eye candy, is apparently <a href="http://exo-blog.blogspot.com/2008/03/windows-2008-vista-done-right.html">noticeably faster than Vista</a> and has none of the nagging security prompt (you are considered administrator though, so keeping safe is entirely up to you).<br />
The 64 bit version can also address the full 4GB of RAM without limitation and all server features are optionally installable.<br />
By default, the installation is actually pretty minimal and you have to set services and options to get Windows configured as a proper workstation. It is after all, meant to be a server.<br />
Oh, I almost forgot that there is also support for <a href="http://en.wikipedia.org/wiki/Hyperv">HyperV</a>, although you must make sure you download the right version (if you list all available downloads in your MSDN subscription, you&#8217;ll see some that are explicitly without that technology).</p>

<h3>Installing Windows Server 2008 x64 is remarkably easy.</h3>

<ul>
<li>Get your hands on the ISO from your MSDN subscription or an install DVD from somewhere else (like a MS event, or even as a <a href="www.microsoft.com/windowsserver2008">free 240 days download from Microsoft</a>).</li>
<li>You&#8217;ll need to repackage the ISO as it won&#8217;t work properly (something to do with <a href="http://support.microsoft.com/kb/931708">non-standard file naming options</a>).<br />
It&#8217;s fairly easy if you follow the instructions from <a href="http://jowie.com/blog/post/2008/02/24/Select-CD-ROM-Boot-Type-prompt-while-trying-to-boot-from-Vista-x64-DVD-burnt-from-iso-file.aspx">Jowie&#8217;s website</a> <em>(<a href="/wp-content/uploads/2008/08/Select-CD-ROM-Boot-Type-prompt-while-trying-to-boot-from-Vista-x64-DVD-burnt-from-iso-file.aspx.htm">cached version</a>)</em>: you can get the <a href="http://www.imgburn.com/">ImgBurn</a> software for free as well, which is a good find in itself. It should&#8217;t take more than 30 minutes to repackage the DVD.</li>
<li>In OSX, go to Applications > Utilities > Boot camp and follow the instructions on screen.<br />
You will be able to resize the default partition by just moving the slider. I left 60GB for OSX and allocated the rest to Windows. The good thing is that OSX can read Windows partitions, so you can always store data there. Windows however, can&#8217;t read the <a href="http://en.wikipedia.org/wiki/HFS_Plus">HFS+</a> mac file system, although there are some third-party tools that can do it  <a href="http://www.ufsexplorer.com/">[1]</a> <a href="http://www.macdisk.com/prospen.php3">[2]</a> <a href="http://www.acutesystems.com/">[3]</a>.</li>
<li>Insert your repackaged DVD and Bootcamp will have rebooted the machine.<br />
After a few minutes of blank screen (and no HDD activity light to let you know something is happening), windows setup launches.</li>
<li>You will be then prompted with the choice of partition to install to.<br />
Select the one named BOOTCAMP, then click the <em>advanced options</em> button and click <em>format</em>.
From there one, windows will install everything, then reboot, then carry on installing, then reboot one last time.</li>
<li>Now, insert your <em>OSX recovery CD 1</em>. It should automatically launch the driver installation.<br />
Once done, you&#8217;ll reboot to a nice, full-resolution windows prompt.</li>
<li>All drivers will have been installed correctly except the one for Bluetooth. To easily solve that issue, just go to <a href="http://www.harbar.net/Default.aspx">Spencer Harbar&#8217;s website</a> and read <a href="http://www.harbar.net/archive/2008/06/13/Enabling-Bluetooth-on-MacBook-Pro-and-Windows-Server-2008-x64.aspx">how to install the Bluetooth drivers</a>. Takes 5 minutes tops.</li>
</ul>

<h3>The final touches</h3>

<p>A few notes to quickly get things running as expected.</p>

<ul>
<li>Get the most of your configuration by following the <a href="http://blogs.msdn.com/vijaysk/archive/2008/02/11/using-windows-server-2008-as-a-super-desktop-os.aspx">list of tweaks from Vijayshinva Karnure</a> from Microsoft India.</li>
<li>There are <a href="http://www.win2008workstation.com/wordpress/">more tweaks</a>, and <a href="http://weblogs.asp.net/israelio/archive/2008/02/21/windows-server-2008-as-workstation.aspx">even more tweaks</a> available as well (don&#8217;t forget to enable <a href="http://www.2008server.org/?q=SuperFetch">Superfetch</a>).</li>
<li>Microsoft has a whole KB entry on <a href="http://support.microsoft.com/kb/947036">enabling user experience</a>.</li>
<li>In the Control Panel > System > Advanced System Settings > Advanced > Settings > Advanced > Processor scheduling, set to <em>Programs</em> instead of <em>Background services</em>.</li>
<li>Activate your copy of Windows using Control Panel > System.<br />
I was getting an error code 0x8007232B <em>DNS name does not exist</em> error. To force activation, just click on the <em>Change Product Key</em> button and re-enter the same key you used during install.<br />
Windows will activate straight away.</li>
<li>When booting your Macbook, press the <em>Option</em> key and you will be presented a list of boot choices.</li>
<li>You can check on <a href="http://www.apple.com/support/bootcamp/">Apple&#8217;s Bootcamp webpage</a> other information about how to use the track pad, keyboard layouts etc,</li>
</ul>

<h3>References</h3>

<ul>
<li><a href="http://stuartd.blogspot.com/2008/04/windows-server-2008-boot-camp-and.html">http://stuartd.blogspot.com/2008/04/windows-server-2008-boot-camp-and.html</a></li>
<li><a href="http://burnetts.homeserver.com/post/Windows-Server-2008-on-the-Mac.aspx">http://burnetts.homeserver.com/post/Windows-Server-2008-on-the-Mac.aspx</a></li>
<li><a href="http://csaborio.wordpress.com/2008/03/28/installing-windows-server-2008-on-a-mac-book-pro/">http://csaborio.wordpress.com/2008/03/28/installing-windows-server-2008-on-a-mac-book-pro/</a></li>
<li><a href="http://exo-blog.blogspot.com/2008/03/windows-2008-vista-done-right.html">http://exo-blog.blogspot.com/2008/03/windows-2008-vista-done-right.html</a></li>
<li><a href="http://www.sturmnet.org/blog/archives/2008/10/02/stuff-i-use-on-the-mac/">http://www.sturmnet.org/blog/archives/2008/10/02/stuff-i-use-on-the-mac/</a> Lots of software recommendations for someone switching from Windows to the Mac.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2008/mac-installing-windows-server-2008-x64-on-a-macbook-pro/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Linux: AutoCAD DWG to SVG preview conversion.</title>
		<link>http://blog.nkadesign.com/2008/linux-autocad-dwg-to-svg-preview-conversion/</link>
		<comments>http://blog.nkadesign.com/2008/linux-autocad-dwg-to-svg-preview-conversion/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 09:16:15 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=95</guid>
		<description><![CDATA[Years ago I did a small utility to convert DWG or DXF files into a vector-graphic, zoomable, SVG preview. The Linux command-line utility was used in a larger drawing management application that I had built before I left that company for greener pastures. The Linux server-based application would scan the vast (100,000s of CAD drawings) [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/linux.png" alt="Linux" title="Linux" align="left" width="54" height="64" hspace="5" vspace="5" border="0" />
Years ago I did a <a href="http://etc.nkadesign.com/Download/Cad2svg">small utility</a> to convert <a href="http://en.wikipedia.org/wiki/.dwg">DWG</a> or <a href="http://en.wikipedia.org/wiki/AutoCAD_DXF">DXF</a> files into a vector-graphic, zoomable, <a href="http://en.wikipedia.org/wiki/Svg">SVG</a> preview.
The Linux command-line utility was used in a larger drawing management application that I had built before I left that company for greener pastures.</p>

<p>The Linux server-based application would scan the vast (100,000s of <a href="http://en.wikipedia.org/wiki/Computer-aided_design">CAD drawings</a>) and, depending on their format, attempt to create thumbnails and extract textual information from them and populate a database so we could easily find related drawings through a simple web-interface.</p>

<p><img src='/wp-content/uploads/2008/07/sshot-390.png' alt='CAD File'  style="float:right;margin-left:10px;margin-bottom:5px"/> The software would present thumbnails of the drawings; when the drawing was in DWG or DXF format, the thumbnail would be an SVG vector representation of the original drawing instead of an image. That made the preview much more useful as you could zoom in and still retain enough detail to ascertain if the drawings was actually what you were looking for.</p>

<p>Other file formats (<a href="http://en.wikipedia.org/wiki/Tagged_Image_File_Format">TIFF</a>, <a href="http://en.wikipedia.org/wiki/HPGL">HPGL</a> plots, etc) were transformed into <a href="http://en.wikipedia.org/wiki/Portable_Network_Graphics">PNG</a> image previews that were saved into 2 size: a small thumbnail, good enough to be displayed in a list, and a larger one that would show more details.</p>

<p>The server software was written in <a href="http://www.perl.org/">Perl</a>, with some of the converters in <a href="http://en.wikipedia.org/wiki/C_(programming_language)">C</a>. Every night, the server would go through the whole tree of drawings on the filesystem, looking for drawings it hadn&#8217;t seen before and it would pass them to the appropriate plug-in for extracting text -where possible- and create thumbnails.</p>

<p>Memories of fun projects&#8230;</p>

<h3>Download links:</h3>

<ul>
<li>cad2svg: <a href="http://etc.nkadesign.com/Download/Cad2svg">http://etc.nkadesign.com/Download/Cad2svg</a></li>
<li>cad2text: <a href="http://etc.nkadesign.com/Download/Cad2text">http://etc.nkadesign.com/Download/Cad2text</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2008/linux-autocad-dwg-to-svg-preview-conversion/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>MS Access: checking network paths without freezing your application</title>
		<link>http://blog.nkadesign.com/2008/ms-access-checking-network-paths-without-freezing-your-application/</link>
		<comments>http://blog.nkadesign.com/2008/ms-access-checking-network-paths-without-freezing-your-application/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 08:48:31 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MSAccess]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=93</guid>
		<description><![CDATA[Access programming is inherently single-threaded. That&#8217;s usually OK as most operations are sequential anyway and it keeps things simple at the programming level. There are times though where the lack of ability to run code on another thread is sorely missing: anything that takes a long time to run will just freeze the application, making [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/access.png" alt="Microsoft Access" title="Microsoft Access" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />
Access programming is inherently single-threaded. That&#8217;s usually OK as most operations are sequential anyway and it keeps things simple at the programming level.<br />
There are times though where the lack of ability to run code on another thread is sorely missing: anything that takes a long time to run will just freeze the application, making it unresponsive and appearing to be locked and about to crash to the user.</p>

<h3>Checking for the existence of network paths</h3>

<p>Checking for the existence of network paths (directories or files) is one of these issues that can freeze an application for 30 seconds or more if the folder is not accessible.</p>

<p>This is a type of problem that benefits greatly from running in a separate thread: it can take such a long time that the best way to check for these remote paths is to launch the verification for their existence outside of Access and somehow get the result back and cache it for the current session so we don&#8217;t have to suffer these delays again every time we check for that path&#8217;s existence.</p>

<p>One easy way to do achieve that goal is to create plain DOS batch files that execute hidden from view, create a result file when they complete their task and delete themselves automatically when they are finished.</p>

<h3>How to use it</h3>

<p>Download the sample database below then just add the <code>FileUtilities</code>, <code>HashTable</code> and <code>MD5</code> modules to your project and you can use the code as such:</p>

<p><textarea name="code" class="vb:nogutter">
Dim status As AsyncDirectoryStatus
status = FileUtilities.PathExistAsync("\\123.45.67.89\shared folder")
</textarea>
The <code>status</code> variable will return either of the following values:</p>

<ul>
<li><code>AsyncDirectoryStatus.OK</code> if the path was found.</li>
<li><code>AsyncDirectoryStatus.NotFound</code> if the path was not found (either because it doesn&#8217;t exist or you don&#8217;t have the rights to access it).</li>
<li><code>AsyncDirectoryStatus.Checking</code> if the verification is in progress and we haven&#8217;t received a definite answer yet.<br />
It&#8217;s up to you to decide how you want to handle that case. You could periodically check it, like I did in the example database, or you could disable the controls until you&#8217;re getting a confirmed result (by checking every time the user performs some action, like moving from record to record in a datasheet for instance).</li>
</ul>

<p>You can call <code>PathExistAsync</code> as often as you want to check the status: it will not slow down your application (read the <em>optional arguments</em> section below though).<br />
The result of the verification is cached, so querying the existence of the path is actually only done once; the result of subsequent queries for the same path is just instantly retrieved from memory.</p>

<h3>Optional arguments</h3>

<p>If you want to force the actual re-checking of a path without using the cached value, you can simply pass the <code>ForceCheck</code> optional parameter:
<textarea name="code" class="vb:nogutter">
Dim status As AsyncDirectoryStatus
status = FileUtilities.PathExistAsync("\\123.45.67.89\shared folder", ForceCheck:=true)
</textarea>
The first time you query for a path (or force it to be rechecked) there will be a short 150ms delay to give a chance to the function to return its result straight away (in case the path can be resolved quickly).<br />
This may not be desirable if you&#8217;re checking a bunch of directories at a time. For instance, this is what I do when my application launches:
<textarea name="code" class="vb:nogutter">
' Check a bunch of paths in parallel
PathExistAsync strPathToQualityDocuments, NoDelay:=true
PathExistAsync strPathToFinancialDocuments, NoDelay:=true
PathExistAsync strPathToShippingDocuments, NoDelay:=true
PathExistAsync strPathToPurchasingDocuments, NoDelay:=true
</textarea>
By querying the existence of all these paths as soon as my application launches, I am starting the verification process without introducing delays in the application itself: each verification will start in its own process, in parallel to the main application.<br />
Later in the application, when I need to actually use these paths, their result is likely to be known.</p>

<h3>How it works</h3>

<p>The <code>FileUtilities</code> module contains the main code.<br />
In it, the <code>PathExistAsync</code> function works in slightly different ways depending on whether it&#8217;s the first time it is being called for a particular path or not.</p>

<p><strong>The first time</strong><br />
The first time the function is called for a given path, we create in the user&#8217;s temporary folder the small batch file whose name is simply a MD5 hash (see below) of the path with <code>.bat</code> appended to it.<br />
This batch file simply checks for the existence of the path and will create a small file (whose name is the MD5 hash of the path) with either <code>0</code> or <code>1</code> in it depending on the result of the verification.<br />
We initially cache the status of the verification for the Path into the <code>AsyncDirectories</code> hashtable (see below) as <code>Checking</code>.</p>

<p>Example of batch file automatically created to verify a path:
<textarea name="code" class="bat">
IF NOT EXIST "\\123.56.78.9\going nowhere" GOTO NOTEXIST
echo 1 > "C:\DOCUME~1\Renaud\LOCALS~1\Temp\463C7367D8329BD6209A65A70A7DA08C"
GOTO END
:NOTEXIST
echo 0 > "C:\DOCUME~1\Renaud\LOCALS~1\Temp\463C7367D8329BD6209A65A70A7DA08C"
:END
DEL %0</textarea>
The Batch file name is <code>463C7367D8329BD6209A65A70A7DA08C.bat</code> where the long number is actually the MD5 hash of the path we&#8217;re checking <code>\\123.56.78.9\going nowhere</code>.</p>

<p><strong>Getting back the result</strong><br />
Whenever the <code>PathExistAsync</code> function is called, we check the currently cached result from the <code>AsyncDirectories</code> hastable.<br />
If it is still <code>Checking</code> then we try to verify if we the result file has been created from the running batch. If not, we just return the same status, if yes, we read the result from the file, save it in the hashtable and delete the result file.</p>

<h3>Useful libraries</h3>

<p>The code makes use of 2 extremely useful libraries that I end up using quite often:</p>

<ul>
<li><p><strong>a <a href="http://en.wikipedia.org/wiki/Hash_table">HashTable</a> implementation.</strong><br />
It makes it easy to create hashtable objects (otherwise known as <em>Associative Arrays</em>) to store and retrieve key/value pairs quickly.<br />
Hashtables are often used to cache data and can be thought of arrays where the index is a string value instead of an number.<br />
Here I use a hashtable to keep track of the paths we&#8217;ve checked and their result.</p></li>
<li><p><strong>a <a href="http://en.wikipedia.org/wiki/Md5">MD5</a> hash implementation.</strong><br />
MD5 is a way to get a somewhat unique fixed-length value from a chunk of data.<br />
It&#8217;s a mathematical function that guarantees that a small change in input (say a single bit in the input data) has a large effect on the output value (a totally different number will be generated) and that you can&#8217;t reverse the function (you can&#8217;t obtain the input just by looking at the output).<br />
It is often used in security applications to transform sensitive data like passwords into unique values that can be (somewhat) safely stored because you can&#8217;t easily reverse a md5.<br />
Well, MD5 are <a href="http://en.wikipedia.org/wiki/Md5#Vulnerability">not that secure</a> any longer but here we just use their ability to transform our path into a unique number that we can easily use as a filename and a key for our hash to retrieve the current status of the path being checked.</p></li>
</ul>

<h3>Sample database</h3>

<p><a href='http://blog.nkadesign.com/wp-content/uploads/2008/06/pathexistasync01.zip' title='Sample database'><img src="/wp-content/uploads/2008/05/download.png" alt="Download" /></a>Download the <a href='http://blog.nkadesign.com/wp-content/uploads/2008/06/pathexistasync01.zip' title='Test database'>PathExistAsync01.zip (67KB)</a> containing the  <strong>Access 2007 ACCDB</strong> database.</p>

<p><a href='http://blog.nkadesign.com/wp-content/uploads/2008/06/pathexistasync02b.zip' title='Sample database'><img src="/wp-content/uploads/2008/05/download.png" alt="Download" /></a>Download the <a href='http://blog.nkadesign.com/wp-content/uploads/2008/06/pathexistasync02b.zip' title='Test database'>PathExistAsync02b.zip (121KB)</a> containing the <strong>MDB</strong> database<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> (untested as I only have Access 2007).</p>

<p><center><img src="/wp-content/uploads/2008/06/sshot-112.png" alt="Test Database" /></center></p>

<h3>License</h3>

<p>Please refer to the source code in the database for the exact licensing terms.<br />
Note that the license only refers to code by me. When code from other sources is used, you will have to conform to their own licensing terms.</p>

<p><!--- Code source license -->
<a rel="license" href="http://creativecommons.org/licenses/by/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by/3.0/80x15.png"/></a><br/>This <span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/Text" rel="dc:type">work</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</a>.</p>

<h3>References</h3>

<ul>
<li><a href="http://www.bytemycode.com/snippets/snippet/251/119/">Hashtable implementation in VB</a></li>
<li><a href="http://www.di-mgt.com.au/crypto.html">Cryptography Software Code</a> (for the MD5 hash implementation in VB)</li>
</ul>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>A specific version for Access 2000 now included in the archive (updated 25JUL2008).&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2008/ms-access-checking-network-paths-without-freezing-your-application/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Now I can prove Microsoft is an evil corporation</title>
		<link>http://blog.nkadesign.com/2008/now-i-can-prove-microsoft-is-an-evil-corporation/</link>
		<comments>http://blog.nkadesign.com/2008/now-i-can-prove-microsoft-is-an-evil-corporation/#comments</comments>
		<pubDate>Fri, 13 Jun 2008 03:52:19 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=89</guid>
		<description><![CDATA[It&#8217;s official, Gold Member is working for Microsoft, apparently doing some evil research in an unnamed Microsoft lair. Here is the absolute proof: He calls himself Erik Meijer now and apparently solved his skin issue but you only need to listen to them to know it&#8217;s the same person. Yes, they are both Dutch, which [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/mood02.png" alt="mood02.png" title="mood02.png" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />It&#8217;s official, Gold Member is working for Microsoft, apparently doing some evil research in an unnamed Microsoft lair.</p>

<p>Here is the absolute proof:</p>

<p><center><img src="/wp-content/uploads/2008/06/goldmember01.jpg" alt="Evil Gold Member" /></center>
<center><img src="/wp-content/uploads/2008/06/217552217_57aa333e41_o.jpg" alt="Erik Meijer" /></center></p>

<p>He calls himself <a href="http://research.microsoft.com/~emeijer/">Erik Meijer</a> now and apparently solved his skin issue but you only need to listen to them to know it&#8217;s the same person.</p>

<p><center><object width="320" height="243"><param name="movie" value="http://www.youtube.com/v/aRtNfb6D3Mc&#038;hl=en"></param><embed src="http://www.youtube.com/v/aRtNfb6D3Mc&#038;hl=en" type="application/x-shockwave-flash" width="320" height="243"></embed></object></center></p>

<p><center><a target="_blank" href="
http://channel9.msdn.com/posts/AdamKinney/Erik-Meijer-Democratizing-the-Cloud/"><img src="/wp-content/uploads/2008/06/sshot-109.png" alt="Erik Meijer on video" /></a></center></p>

<p>Yes, they are both Dutch, which in itself is already proof enough of their evilness and further confirms they are one and the same.</p>

<p>There is some talk that Microsoft has been the refuge of all that is Bad, and some even say that Steve Ballmer may be none other than Dr Evil himself&#8230;</p>

<p>That being said, you should check out videos on <a href="http://channel9.msdn.com/">Channel 9</a> where <a href="http://research.microsoft.com/~emeijer/">Erik Meijer</a> appears. Despite his obvious evilness, he is actually one of the very bright and interesting characters at Microsoft and always has fascinating things to say about programming languages:</p>

<ul>
<li><a href="http://channel9.msdn.com/shows/Going+Deep/Expert-to-Expert-Erik-Meijer-and-Bertrand-Meyer-Objects-Contracts-Concurrency-Sleeping-Barbers/">Expert to Expert: Erik Meijer and Bertrand Meyer -- Objects, Contracts, Concurrency, Sleeping Barbers</a></li>
<li>Tier Splitting Volta: Who. What. How. Why -- <a href="http://channel9.msdn.com/shows/Going+Deep/Tier-Splitting-Volta-Who-What-How-Why-Part-1/">Part 1</a> and  <a href="http://channel9.msdn.com/shows/Going+Deep/Tier-Splitting-Volta-Who-What-How-Why-Part-2/">Part 2</a></li>
<li><a href="http://channel9.msdn.com/shows/Going+Deep/Erik-Meijer-Functional-Programming/">Erik Meijer: Functional Programming</a></li>
<li><a href="http://channel9.msdn.com/shows/Going+Deep/Erik-Meijer-Gilad-Bracha-Mads-Torgersen-Perspectives-on-Programming-Language-Design-and-Evolution/">Erik Meijer, Gilad Bracha, Mads Torgersen: Perspectives on Programming Language Design and Evolution</a></li>
<li><a href="http://channel9.msdn.com/posts/scobleizer/Paul-Vick-and-Erik-Meijer-Dynamic-Programming-in-Visual-Basic/">Paul Vick and Erik Meijer -- Dynamic Programming in Visual Basic</a></li>
<li><a href="http://channel9.msdn.com/posts/AdamKinney/Erik-Meijer-Democratizing-the-Cloud/">Erik Meijer: Democratizing the Cloud</a></li>
<li><a href="http://channel9.msdn.com/shows/Going+Deep/Anders-Hejlsberg-Herb-Sutter-Erik-Meijer-Brian-Beckman-Software-Composability-and-the-Future-of/">Anders Hejlsberg, Herb Sutter, Erik Meijer, Brian Beckman: Software Composability and the Future of the CLR</a></li>
<li>JAOO 2007: Joe Armstrong -- On Erlang, OO, Concurrency, Shared State and the Future, <a href="http://channel9.msdn.com/posts/Charles/JAOO-2007-Joe-Armstrong-On-Erlang-OO-Concurrency-Shared-State-and-the-Future-Part-1/">Part 1</a> and <a href="http://channel9.msdn.com/posts/Charles/JAOO-2007-Joe-Armstrong-On-Erlang-OO-Concurrency-Shared-State-and-the-Future-Part-2/">Part 2</a></li>
<li>CLR Team Tour -- The Future of Languages (PDC panel preview) -- <a href="http://channel9.msdn.com/posts/scobleizer/CLR-Team-Tour-Part-I-Preparing-for-the-PDC/">Part 1</a> and <a href="http://channel9.msdn.com/posts/scobleizer/CLR-Team-Tour-Part-II-The-Future-of-Languages-PDC-panel-preview/">Part 2</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2008/now-i-can-prove-microsoft-is-an-evil-corporation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MS Access: Enhanced Message Box Replacement</title>
		<link>http://blog.nkadesign.com/2008/ms-access-enhanced-message-box-replacement/</link>
		<comments>http://blog.nkadesign.com/2008/ms-access-enhanced-message-box-replacement/#comments</comments>
		<pubDate>Tue, 20 May 2008 10:39:54 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Business]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MSAccess]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=76</guid>
		<description><![CDATA[This project provides a custom and enhanced message box replacement for the default MsgBoxfound in Access. A Test database for Access 2007 is available at the bottom of this post. (Updated Tuesday 17MAR2009.) What&#8217;s wrong with the default MsgBox The default message box in Access is sometimes useful to warn, inform or ask confirmation from [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/access.png" alt="Microsoft Access" title="Microsoft Access" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />
This project provides a custom and enhanced message box replacement for the default <code>MsgBox</code>found in Access. A Test database for Access 2007 is available at the bottom of this post. (<strong>Updated Tuesday 17MAR2009.</strong>)</p>

<h3>What&#8217;s wrong with the default MsgBox</h3>

<p>The default message box in Access is sometimes useful to warn, inform or ask confirmation from the user.
<center><img src="/wp-content/uploads/2008/05/sshot-79.png" alt="Standard MsgBox" /></center></p>

<p>It has, however, a few drawbacks:</p>

<ul>
<li>It is bland: the standard message box does not even follow the currently selected Office 2007 scheme.</li>
<li>The amount of text it can display is limited: if you try to display too much text it will be truncated.</li>
<li>You can&#8217;t copy or save the content of the message.</li>
<li>Because popup boxes are viewed as intrusive, people tend not to read them and end-up closing message boxes before they realize they may have contained useful information.</li>
<li>They only displays plain text: you cannot format the message to draw attention to the key points.</li>
<li>They are blocking, meaning that nothing can happen in the main application while the box is displayed (it can&#8217;t even shut down).</li>
</ul>

<p>Sometimes you need to display an important message or require users to make take a decision.<br />
Message boxes are not to be abused but they serve a useful purpose.</p>

<h3>An enhanced message box</h3>

<p>Rather than using the bland standard message box you can now have something a bit more customized.</p>

<p><strong>Plain Text</strong> version of the enhanced custom message box under the Office Blue Colour Scheme:
<center><img src="/wp-content/uploads/2008/05/sshot-81.png" alt="Plaintex Enhanced Message Box" /></center></p>

<p><strong>RichText</strong> version of the enhanced custom message box under the Office Black Colour Scheme:
<center><img src="/wp-content/uploads/2008/05/sshot-78.png" alt="RichText Enhanced Message Box" /></center></p>

<p>Here are the features of the enhanced message box:</p>

<ul>
<li>It is entirely compatible with the standard one: just change <code>MsgBox</code> to <code>Box</code> 
using <em>find and replace</em> should be enough (see tip below to avoid getting strange errors).</li>
<li>It allows the user to simply click on a button to copy the content of the message to 
the clipboard or save it to a text file to a configurable default location.</li>
<li>It looks and feels like it belongs to the main application, following its colour scheme.</li>
<li>It attempts to prevent users from blindly closing the modal box reading the message: buttons will first be inactive for a configurable amount of time. It&#8217;s not a perfect solution, but it is quite effective.</li>
<li>There is a <code>RichBox</code> version that can display rich HTML content, not just plain text, so important parts of the message can be formatted in a useful way.</li>
<li>It is able to display large amount of data. While it&#8217;s not something you usually want, it may be useful for the message box to display more text in some situations (log or tracing information, legal documentation, etc).</li>
<li>Rather than sprinkling your code with &#8220;<code>&amp; vbCrLf &amp; _</code>&#8221; uglies, you can embed newlines in the text itself by using C-style &#8220;<code>\n</code>&#8221; escape sequences that will automatically be transformed into the appropriate newlines. Makes for clearer code and less typing.</li>
<li>Because you get the source, you can easily customise the message box with new icons and colours to better match your overall application&#8217;s personality.</li>
<li>It is non-blocking: if your application forces users to log-off after a certain amount of inactivity, the enhanced message box will just close rather than prevent Access from shutting down like the standard <code>MsgBox</code> does. Of course, it&#8217;s up to you to decide how to handle that gracefully, if at all.</li>
<li>It properly displays the expected button captions based on the language of the operating system, so it behaves very much like the default <code>MsgBox</code> (for instance, it will properly display &#8220;<em>Cancel</em>&#8221; on English systems and &#8220;<em>Annuler</em>&#8221; on French ones).</li>
<li>It also properly plays the system sounds associated with the type of message. You can also enable or disable the sound effect as needed.</li>
</ul>

<h3>How to use it</h3>

<p>Download the demo below and copy (drag &amp; drop) the following into your application:</p>

<ul>
<li>the <code>FormDialog</code> form,</li>
<li>the <code>API_GetTextMetrics</code> module,</li>
<li>the <code>Dialog</code> module.</li>
</ul>

<p>If you rename the <code>FormDialog</code>, make sure you replace any occurrence to it in the code, in particular in the <code>Dialog</code> module.</p>

<p>Since the enhanced message box is just a replacement for the standard one, you just use it like you  would use the <code>MsgBox</code>.<br />
<textarea name="code" class="vb:nogutter">
'-----------------------------------------------------------------------------
' Simple use of the Plaintext box
' Note the use of n that will be converted into a newline
Dialog.Box "This is a plaintext message.\nClick OK to dismiss", 
           vbOKOnly+vbinformation, _
           "Message Title"

'-----------------------------------------------------------------------------
' Getting the result back
Dim dr as vbMsgBoxresult
dr = Dialog.Box("Are you sure you want to delete?", _
     vbYesNoCancel+vbQuestion, "Confirm action")
if (dr = vbYes) then DeleteRecords

'-----------------------------------------------------------------------------
' Using named parameters
Dialog.Box Prompt:="All your bases are belong to us", _
           Buttons:=(vbOkOnly+vbCritical), _
           Title:="Bad error"

'-----------------------------------------------------------------------------
' Using the RichBox to display simple HTML
' The first line will be bold, then the word 'button' will be printed in red
' Here the n will be escaped to '<br/>' tags to simulate newlines.
Dialog.RichBox "<strong>This is a bold message</strong>.\n" & _
               "Click the <font color=""#FF0000"">button</font> to dismiss.", 
               vbOKOnly+vbinformation, _
               "RichText Message Title"
</textarea>
There are a few additional settings that can be used to change the behaviour of the enhanced message boxes.<br />
One is that you can adjust the delay before the buttons become activated.<br />
<textarea name="code" class="vb:nogutter">
'-----------------------------------------------------------------------------
' Use the ButtonDelay to specify the time in seconds before the buttons become activated
' The default is 2s. Use 0 to activate the buttons immediately.
Dialog.Box Prompt:="All your bases are belong to us", _
           Buttons:=(vbOkOnly+vbCritical), _
           Title:="Bad error",
           ButtonDelay:=1

'-----------------------------------------------------------------------------
' Change the default delay value.
' To disable the activation delay
Dialog.DefaultButtonDelay = 0

' To make the user wait 3 seconds before they can press any button
Dialog.DefaultButtonDelay = 3</textarea>
Another one is that you can enable or disable whether beeps should be played or not.<br />
<textarea name="code" class="vb:nogutter">
'-----------------------------------------------------------------------------
' Use AllowBeep to specify whether beeps should be played when the message box opens
' By default, they are.
Dialog.Box Prompt:="All your bases are belong to us", _
           Buttons:=(vbOkOnly+vbCritical), _
           Title:="Bad error",
           AllowBeep:=false

'-----------------------------------------------------------------------------
' Change the default behaviour. This is true by default.
Dialog.DefaultAllowBeep = false
</textarea>The last settings is the folder where we should save the content of the message when the user clicks the Save button on the message box.<br />
<textarea name="code" class="vb:nogutter">
'-----------------------------------------------------------------------------
' Change the save folder.
' By default, the text messages will be saved in the same directory as the database.
' Here we want them to be saved to a temp directory
Dialog.DefaultSavedTextFileFolder= "C:temp"
</textarea>
These few settings make the enhanced message box more customizable.</p>

<h3>Large text</h3>

<p>The standard <code>MsgBox</code> cannot display much text. On the other hand, there is no real limitation to the amount of text the <code>Box</code> and <code>RichBox</code> can display.<br />
When the amount of information is too much to fit the maximum allowed size for the message box the text will overflow and can be scrolled up/down as necessary.</p>

<h3>Limitations of the RichBox</h3>

<p>The <code>RichBox</code> version relies on the normal TextBox control&#8217;s ability under Access 2007 to display RichText wich is nothing more than lightweight HTML.<br />
Because font size may be varying a lot in the message, it becomes very difficult to accurately predict the size of the box needed to display the whole message.<br />
Short of implementing a complete HTML engine, we have to rely on some assumptions to display HTML.<br />
The risk is that sometimes the content may not properly fit the TextBox control in some circumstances.<br />
If you use the <code>RichBox</code>, thoroughly try displaying your messages and tweak the HTML as necessary to include additional lines or non-breaking spaces to ensure that the result looks good.<br />
If you don&#8217;t overuse font size and don&#8217;t display in multiple fonts the <code>RichBox</code> should do the right thing most of the time.<br />
Don&#8217;t overuse the <code>RichBox</code> to display colourful messages. There is a fine line between being informative and tasteless. Keep colours and formatting where it is useful.<br />
I think that in most cases, the plain text version <code>Box</code> is more than enough.</p>

<h3>Replacing MsgBox in existing code</h3>

<p>As I said above, replacing the standard <code>MsgBox</code> is easy but you need to make sure your search and replace parameters are configured correctly:
<center><img src="/wp-content/uploads/2008/05/sshot-407.png" alt="Search and replace options" /></center></p>

<p>If you&#8217;re getting strange compile errors, it may be because you forgot to tick the <em>Find Whole Word Only</em> and some of the strings containing the letter sequence &#8220;msgbox&#8221; were replaced in the process.</p>

<p>If that&#8217;s the case, you can revert the damage by simply doing a search and replace across the whole project on:<br />
- <code>VbboxStyle</code> or <code>VbDialog.BoxStyle</code> to be replaced with <code>VbMsgBoxStyle</code><br />
- <code>VbboxResult</code> or <code>VbDialog.BoxResult</code>to be replaced with <code>VbMsgBoxResult</code></p>

<h3>How it works</h3>

<p>The code makes extensive use of Win32 API calls.<br />
Most of the hard work is done in the <code>FomDialog</code> class form. There is too much there to really go into the details but you are welcome to have a look at the commented code.<br />
The code relies also on a utility function from <em>Stephen Lebans</em> used to calculate the size of of text. I have made some minor modification to that code so I would refer you to his original implementation if you are interested in calculating TextBox sizes for forms or reports.</p>

<p>In the code for the <code>FormDialog</code>, I re-implement some of the expected functionalities of the <code>MsgBox</code>: proper arrangement of the buttons, displaying of the appropriate icon, etc.<br />
Once this is done, we calculate the size of the textbox needed to display the whole of the message.<br />
In the case of RichText, we first use <code>Application.PlainText()</code> to convert the HTML into properly formatted plain text. We then calculate the Textbox size using a slightly larger font than needed as a way to ensure that the content of the RichText message will fit the box in most cases.<br />
Once we know the size of the TextBox, we can easily resize the form to properly display the TextBox.<br />
If there is too much text, we resize the form to its maximum permissible (70% or screen width and 90% of screen height) and change some of the visual cues to let the user know the text is overflowing.</p>

<p>One thing of note is the way the form is kept modal.<br />
Rather than using <code>DoCmd.OpenForm</code> and <code>DoCmd.Close</code> I use the form as a class and create an instance manually (see the code in <code>Dialog.Box</code> and <code>Dialog.Richbox</code>). I keep this instance alive until I got the form&#8217;s result back.<br />
If you are interested in knowing how the form is made modal, this is the code in <code>FormDialog.ShowModal()</code> what keeps the form open until the user clicks a button:<br />
<textarea name="code" class="vb">
Public Function ShowModal() As VbMsgBoxResult
   ...
    ' Here we reset the result for the clicked button such as vbOK, vbYes, etc
    ' This is set in each Button's Click event
    m_Result = -1
    ' Wait for the user to click a button
    Do While (m_Result = -1)
        DoEvents
        Sleep 50
    Loop
    ShowModal = m_Result
End Function</textarea>
The <code>Sleep()</code> function is a Win32 API that stops the current process for the given number of milliseconds. This in effects hands back the control to the Operating System for a short time. That way the system is still responsive and does not consume resources when it&#8217;s just waiting for user input.</p>

<h3>Sample database</h3>

<p>You can download a sample database containing all the necessary code as well as a number of tests.<br />
This version only contains the database in Microsoft Access 2007 accdb format.
<center><img src="/wp-content/uploads/2008/05/sshot-77.png" alt="Sample database testing form" /></center></p>

<p><a href='http://blog.nkadesign.com/wp-content/uploads/2008/05/EnhancedMsgBox01.zip' title='Sample database'><img src="/wp-content/uploads/2008/05/download.png" alt="Download" /></a>Download the <a href='http://blog.nkadesign.com/wp-content/uploads/2008/05/EnhancedMsgBox01.zip' title='Test database'>EnhancedMsgBox01.zip (116KB), v1.3</a> containing the ACCDB database.</p>

<h3>Code Updates</h3>

<p><em>v1.3: 17MAR2009</em><br />
Thanks to Henry of <a href="http://www.access-pro.de/">Access-Pro.de</a> for proposing a correction to the default buttons behaviour.</p>

<ul>
<li>Updated behaviour for the default buttons. They are now focused in a way that matches that of the standard msgbox.</li>
<li>Reversed the naming of the buttons on the form to make it a bit more consistent with the standard box.</li>
</ul>

<p><em>v1.2: 07SEP2008</em><br />
Thanks to Andy Colonna (<a href="http://www.pcesoft.com">http://www.pcesoft.com</a>) for uncovering the following bugs (check out his <a href="http://www.pcesoft.com/Access-Spell-Checker-Tool-Source-Code.html">free Spell Checker with source code</a>!):</p>

<ul>
<li>Corrected bug in <code>Form_FormDialog.FilenameSanitize()</code> function that would 
fail to remove all invalid characters for a file name.</li>
<li>File name for the saved text message will be truncated to first 32 characters 
of message box title in <code>Form_FormDialog.MakeFriendlyFileName()</code>.</li>
<li>Changed the use of <code>FollowHyperlink</code> to <code>ShellExecute</code> to avoid security warning
in some instances in <code>Form_FormDialog.btCopyToFile_Click()</code></li>
<li>Corrected twips to pixel conversion bug in <code>API_GetTextMetrics.fTextWidthOrHeight()</code> that 
would result in an improperly sized dialog box when the text message was too 
wide.</li>
</ul>

<p><em>v1.1: 08AUG2008</em></p>

<ul>
<li>Corrected code for <code>DefaultButtonDelay</code> (thanks to Geoffrey) (was referencing
wrong variable, causing self-referencing code).</li>
<li>Corrected code for <code>Box</code> and <code>RichBox</code> to take the <code>DefaultSavedTextFileFolder</code>
into account (the path was previously not passed onto the dialog boxes and 
the text file would always be created in the application folder instead of 
the one specified by <code>DefaultSavedTextFileFolder</code>)</li>
<li>Added license notice at top of source code.</li>
</ul>

<p><em>v1.0: 20MAY2008</em></p>

<ul>
<li>Original version</li>
</ul>

<h3>Resources</h3>

<ul>
<li><a href="http://www.codeproject.com/KB/dialog/MessageBoxEx.aspx">Dissecting the MessageBox</a> article on <a href="http://www.codeproject.com/">CodeProject</a></li>
<li><a href="http://www.codeproject.com/KB/dialog/xmessagebox.aspx">XMessageBox -- A reverse-engineered MessageBox()</a> article on <a href="http://www.codeproject.com/">CodeProject</a></li>
<li><a href="http://www.lebans.com/textwidth-height.htm">TextWidth-Height code demo</a> from <a href="http://www.lebans.com/">Stephen Lebans</a> (great resource, check it out!).</li>
<li><a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;210590">Pixel to Twips conversion</a> from MSDN.</li>
<li><a href="http://www.mvps.org/access/api/api0049.htm">Copy Text to Clipboard</a> from the excellent site <a href="http://www.mvps.org/access/">The Access Web</a>.</li>
<li><a href="http://www.thevbzone.com/l_res.htm">Getting Resource Strings and more</a> from DLLs.</li>
</ul>

<p><!--- Code source license -->
<a rel="license" href="http://creativecommons.org/licenses/by/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by/3.0/80x15.png"/></a><br/>This <span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/Text" rel="dc:type">work</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</a>.<br />
Free for re-use in any application or tutorial providing clear credit is made about the origin of the code and a link to this site is prominently displayed where end-users can easily access it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2008/ms-access-enhanced-message-box-replacement/feed/</wfw:commentRss>
		<slash:comments>64</slash:comments>
		</item>
		<item>
		<title>MS Access: Restarting and compacting the database programmatically</title>
		<link>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/</link>
		<comments>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/#comments</comments>
		<pubDate>Tue, 06 May 2008 03:06:19 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MSAccess]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=73</guid>
		<description><![CDATA[In my previous article about changing the MS Access colour scheme I had the need to allow the user to restart the database after the colour scheme was changed. (Article and Code Updated 13FEB2009.) Being able to cleanly restart and compact the application is also useful in other instances: Changes made to the environment Recovering [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/access.png" alt="Microsoft Access" title="Microsoft Access" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />
In my previous article about <a href="http://blog.nkadesign.com/2008/ms-access-changing-the-color-scheme-programmatically/">changing the MS Access colour scheme</a> I had the need to allow the user to restart the database after the colour scheme was changed.<br />
(<strong>Article and Code Updated 13FEB2009.</strong>)</p>

<p>Being able to cleanly restart and compact the application is also useful in other instances:</p>

<ul>
<li>Changes made to the environment</li>
<li>Recovering from errors (for instance after a network disconnection)</li>
<li>Forcing the user to re-log cleanly into the application</li>
<li>Automatically restarting a long-running application (for instance so that it may automatically compact on close and restart afresh with or without user intervention).</li>
</ul>

<p>The problem is that you cannot -to the best of my knowledge- close and open again the same database from within MS Access itself.<br />
Most executables cannot do that and the way to solve the issue is usually to pass the control to another boostrap programme, close the main application and let the bootstrap programme re-open the main application again.<br />
I wanted a simple and clean way of using it. One that would not require shipping external programmes.</p>

<h3>How to use it</h3>

<p>Download the sample database below, copy the <code>Utilities</code> module or just the <code>Restart</code> sub defined in it into your own application.</p>

<p>To use it, just call the <code>Restart</code> sub and the application will close and re-open.<br />
If you supply the optional <code>Compact:=true</code> parameter, the database will also be compacted during the restart process.<br />
This will work for normal databases (mdb/accdb) and also compiled (mde/accde) and runtime (accdr) databases as well.</p>

<h3>Important note</h3>

<p>If you want to use this code do not enable the <em>Compact on Close</em> option in Access for your database as the code doesn&#8217;t pick that up yet.<br />
Instead, you can either simply call <code>restart Compact:=true</code> on user action (for instance from a menu) or on other triggers, for instance when the database is being open and hasn&#8217;t been compacted for more than a week.</p>

<h3>How it works</h3>

<p>If you&#8217;re curious about the technical details, here is how it was put together.<br />
The main idea is that the MS Access database application has to be self-sufficient and restart itself by performing these steps:</p>

<ul>
<li>create a small batch file</li>
<li>run the batch file, passing the path and extension of our database</li>
<li>close the main application</li>
<li>the running batch file would wait for the MS Access lock file to be removed</li>
<li>once the lock file disappears, we open the database after compacting it if required.</li>
</ul>

<p>The key point here is that the batch file cannot just reopen the database right away: if the application is big or if it&#8217;s compacting on close for instance, it may take several seconds to actually close.<br />
The only moment we can be pretty sure that the database is effectively closed is when the lock file is deleted by MS Access.</p>

<p>The batch file is hard-wired in the <code>Restart</code> sub that does all the work:<br />
<textarea name="code" class="bat">
SETLOCAL ENABLEDELAYEDEXPANSION
SET /a counter=0
:CHECKLOCKFILE
ping 0.0.0.255 -n 1 -w 100 > nul
SET /a counter+=1
IF "!counter!"=="60" GOTO CLEANUP
IF EXIST "%~f2.%4" GOTO CHECKLOCKFILE
"%~f1" "%~f2.%3" /compact
start " " "%~f2.%3"
:CLEANUP
del %0
</textarea>
When the application runs the batch file, it passes 4 arguments:</p>

<ul>
<li>the full path to the MSAccess.exe executable (used for compacting the database)</li>
<li>the full path to the database without the extension</li>
<li>the database file extension without the leading &#8220;.&#8221;</li>
<li>the appropriate database lock file extension (<code>laccdb</code> or <code>ldb</code>).</li>
</ul>

<p>This allows us to easily construct the path to either the database or the lock file at line 07 and 09.<br />
Line 08 is actually only inserted if we need to compact the database: it simply launches MSAccess.exe with the <code>/compact</code> command line switch.</p>

<p>The funny use of <code>PING</code> is actually a simple way to wait for some time before we check if the lock file is still there or not. There is not <code>SLEEP</code> or <code>WAIT</code> function provided by default in Windows so we have to be a bit creative and use the time-out option of the <code>PING</code> command trying to ping an inexistent, but valid, IP address.<br />
Once the lock file has disappeared, we open the database at line 09 and then delete the batch file itself so we leave no leftovers.</p>

<p>The other thing of note is that we now use a counter to keep track of the number of times we checked the existence of the lock file.<br />
Once this counter reaches a pre-determined amount (60 by default, ~ 45 seconds) we consider that there is a problem and the database application didn&#8217;t close, so we just exit and delete the batch file.</p>

<p><a href='http://blog.nkadesign.com/wp-content/uploads/2008/05/DatabaseRestart.zip' title='Sample database'><img src='http://blog.nkadesign.com/wp-content/uploads/2008/05/download.png' align="left" alt='Download' /></a>Download the <a href='http://blog.nkadesign.com/wp-content/uploads/2008/05/DatabaseRestart.zip' title='Test database'>DatabaseRestart.zip (48KB)</a> containing both an Access 2007 ACCDB and Access 2000 MDB test databases.</p>

<h3>Other implementations</h3>

<ul>
<li><a href="http://www.rogersaccesslibrary.com/">Roger&#8217;s Access Library</a> (MVP) has a <a href="http://www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=377">different implementation on offer</a>.</li>
</ul>

<h3>Code Updates</h3>

<p><strong>v1.2: 13FEB2009</strong></p>

<ul>
<li>Added optional parameter to compact the database during restart.</li>
</ul>

<p><strong>v1.1: 09AUG2008</strong></p>

<ul>
<li>Now a separate test database (used to be bundled with the Colour Scheme sample).</li>
<li>Added support for older Access versions (an Access2000 MDB is now included).</li>
<li>Corrected wrong lock file extension for accd* files.</li>
<li>Added a time-out feature after which the batch file will delete itself 
after a while if the Access lock file wasn&#8217;t released 
(for instance following a crash).</li>
<li>Added checks to delete the batch file if it has not deleted itself for some
reason (for instance after a reboot).</li>
<li>The batch file now has a unique name based on the name of the database, 
allowing multiple databases to be restarted from the same directory.</li>
<li>Added license notice at top of source code.</li>
<li>Updated the article to reflect the changes.</li>
</ul>

<p><strong>v1.0: 06MAY2008</strong></p>

<ul>
<li>Original version</li>
</ul>

<p><!--- Code source license -->
<a rel="license" href="http://creativecommons.org/licenses/by/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by/3.0/80x15.png"/></a><br/>This <span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/Text" rel="dc:type">work</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>MS Access: Changing the Color Scheme programmatically</title>
		<link>http://blog.nkadesign.com/2008/ms-access-changing-the-color-scheme-programmatically/</link>
		<comments>http://blog.nkadesign.com/2008/ms-access-changing-the-color-scheme-programmatically/#comments</comments>
		<pubDate>Sat, 03 May 2008 13:20:43 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MSAccess]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=72</guid>
		<description><![CDATA[Microsoft Office 2007/2010 comes with 3 colour (color) schemes. Users can easily change it but when you deploy an Access application under the Runtime your users have no way to set the colour scheme as the application&#8217;s options are not available. (Article and Code Updated 31MAY2011.) Luckily for us, Office 2007 stores the global colour [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/access.png" alt="Microsoft Access" title="Microsoft Access" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />
Microsoft Office 2007/2010 comes with 3 colour (color) schemes.
Users can easily change it but when you deploy an Access application under the <a href="http://www.microsoft.com/downloads/en/details.aspx?familyid=57a350cd-5250-4df6-bfd1-6ced700a6715">Runtime</a> your users have no way to set the colour scheme as the application&#8217;s options are not available.<br />
(<strong>Article and Code Updated 31MAY2011.</strong>)</p>

<p>Luckily for us, Office 2007 stores the global colour scheme setting in the registry under:<br />
<code>HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\Theme</code><br />
and Office 2010 in:<br />
<code>HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Common\Theme</code></p>

<p>The values being stored under that key are:</p>

<ol>
<li>Blue scheme</li>
<li>Silver scheme</li>
<li>Black scheme</li>
</ol>

<p>With this information, we can easily both read and set the colour scheme.
The only caveat is that I could not find a way to notify Access to reload the setting automatically once it is changed, so users will have to restart the application before the change becomes active.
A small price to pay but if anyone has a better idea, please let me know.</p>

<p>To write the new value to the registry I use a set of WIN 32 APIs that are more flexible than the default ones provided in VBA.</p>

<p><img src="/wp-content/uploads/2008/05/colorschemes.png" alt="Office 2007 Colour Schemes" title="Office 2007 Colour Schemes" width="560" height="263" hspace="0" vspace="5" border="0" /></p>

<p>You can download the sample database as it contains all necessary files, including the definition for the Win32 API functions.</p>

<p><a href='http://blog.nkadesign.com/wp-content/uploads/2008/05/ColorScheme.zip' title='Sample database'><img src='http://blog.nkadesign.com/wp-content/uploads/2008/05/download.png' align="left" alt='Download' /></a>Download the <a href='http://blog.nkadesign.com/wp-content/uploads/2008/05/ColorSchemeV1.3.zip' title='Test database'>ColorSchemeV1.3.zip (31KB)</a> containing the ACCDB database.</p>

<p>The sample also contains some code to restart the database. This is the subject of another post: <a href="/2008/ms-access-restarting-the-database-programmatically/">Restarting and compacting the database programmatically</a>.</p>

<h3>Improvements/uses:</h3>

<ul>
<li>Find a way for Access to reload the settings without having to restart the application.</li>
<li>Use the knowledge about the current scheme to change the other colour settings in the application (or even adapt the form&#8217;s theme).</li>
</ul>

<h3>Updates:</h3>

<ul>
<li>31MAY2011: added support for Office 2010.</li>
</ul>

<h3>References:</h3>

<ul>
<li><a href="http://blogs.msdn.com/eric_carter/archive/2008/04/11/setting-the-backcolor-to-match-the-office-2007-color-scheme.aspx">Setting the BackColor to match the Office 2007 color scheme</a></li>
<li>API <a href="http://www.arcatapet.net/vbregget.cfm">Get</a> / <a href="http://www.arcatapet.net/vbregset.cfm">Set</a> Registry functions from <a href="http://www.arcatapet.net/">http://www.arcatapet.net/</a>.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2008/ms-access-changing-the-color-scheme-programmatically/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>MS Access: Modal Dialogs with Transparent Backgrounds (redux)</title>
		<link>http://blog.nkadesign.com/2008/ms-access-modal-dialogs-with-transparent-backgrounds/</link>
		<comments>http://blog.nkadesign.com/2008/ms-access-modal-dialogs-with-transparent-backgrounds/#comments</comments>
		<pubDate>Thu, 01 May 2008 11:36:36 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MSAccess]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/2008/ms-access-modal-dialogs-with-transparent-backgrounds/</guid>
		<description><![CDATA[Microsoft Access Team made an interesting post and a follow-up on how to add a transparent layer that cover the screen to focus the attention of the user to a login form or other important popup window. The trick is to use some WIN 32 API calls to modify the transparency of a standard MS [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/access.png" alt="Microsoft Access" title="Microsoft Access" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />
Microsoft Access Team </a>made an <a href="http://blogs.msdn.com/access/archive/2008/04/28/modal-dialogs-with-transparent-backgrounds.aspx">interesting post </a> and a <a href="http://blogs.msdn.com/access/archive/2008/05/05/follow-up-to-transparency-forms.aspx">follow-up</a> on how to add a transparent layer that cover the screen to focus the attention of the user to a login form or other important popup window.</p>

<p>The trick is to use some WIN 32 API calls to modify the transparency of a standard MS Access form made to cover the screen.</p>

<p>The effect is quite neat and I thought I would try it and make a sample database for others to tinker with it.<br />
My version allows you to chose between covering the whole screen or just the main Access window and it will test if it&#8217;s running under a Remote Desktop Terminal and disable the layer in that case.</p>

<p><a rel="lightbox" href="/wp-content/uploads/2008/05/sshot-70.png"><img width="250" vspace="5" hspace="5" height="189" border="0" alt="The transparent layer covering the main Window only" title="The transparent layer covering the main Window only" src="/wp-content/uploads/2008/05/sshot-70sm.png" /></a><a rel="lightbox" href="/wp-content/uploads/2008/05/sshot-73.png"><img width="250" vspace="5" hspace="5" height="189" border="0" alt="The transparent layer covering the full screen" title="The transparent layer covering the full screen" src="/wp-content/uploads/2008/05/sshot-73sm.png" /></a></p>

<h3>Update 07MAY2008</h3>

<p>Following Rob&#8217;s improvements I made another sample database that incorporates his code with a few improvements:</p>

<ul>
<li>I added the <code>LightBoxForm.LayerToFullScreen</code> property so users can choose explicitly how they want the layer to be shown.</li>
<li>I moved the code to hide the layer into a Hide() sub so you can just show/hide the layer using <code>LightboxForm.Show</code> and <code>LightboxForm.Hide</code>.</li>
<li>I changed the Form&#8217;s <code>Resize </code>event code in the <code>LightBoxForm</code> class to avoid flickering: resizing the form within its <code>Resize</code> event actually trigger the <code>Resize</code> event again a second time which causes flickering.<br />
I simply modified the code to make the form totally transparent (opacity of 0) the first time the event is fired and assign it the expected opacity when the event handler in re-entered.  </li>
</ul>

<p><textarea name="code" class="vb">
'-----------------------------------------------------------------------------
' Handle the Layer Form Resize event
'-----------------------------------------------------------------------------
Private Sub m_objForm_Resize()
    Static busyResizing As Boolean
    Dim lngStyle As Long
    Dim r        As RECT

    ' disable screen updates
    m_objForm.Painting = False

    ' When the form opens initially, we make it totally transparent to avoid flickering
    lngStyle = GetWindowLong(m_objForm.hWnd, GWL_EXSTYLE)
    SetWindowLong m_objForm.hWnd, GWL_EXSTYLE, lngStyle Or WS_EX_LAYERED
    SetLayeredWindowAttributes m_objForm.hWnd, 0, 0, LWA_ALPHA
    
    ' If the Access window is maximized, then maximize the lightbox form.
    ' If the Access window is not maximized, then
    ' position the lightbox form so that it covers the Access window
    If IsZoomed(hWndAccessApp()) Or m_bLayerToFullScreen Then
        DoCmd.Maximize
    Else
        GetWindowRect Application.hWndAccessApp(), r
        MoveWindow m_objForm.hWnd, r.x1, r.y1, (r.x2 - r.x1), (r.y2 - r.y1), True
    End If
    
    If busyResizing Then
        ' Get the current window style, then set transparency
        lngStyle = GetWindowLong(m_objForm.hWnd, GWL_EXSTYLE)
        SetWindowLong m_objForm.hWnd, GWL_EXSTYLE, lngStyle Or WS_EX_LAYERED
        SetLayeredWindowAttributes m_objForm.hWnd, 0, (m_sngOpacity * 255), LWA_ALPHA
        ' enable screen updates
        m_objForm.Painting = True
        ' Back to normal
        busyResizing = False
    Else
        busyResizing = True
    End If
End Sub
</textarea></p>

<h3>Samples</h3>

<p>There are now 2 sample databases. Ech zip contains a Microsoft Access 2007 ACCDB file and its conversion to Access 2000<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> and Access 2002-2003 MDB but please note that I have not been been able to test those in older version of Access and that form transparency doesn&#8217;t work in Operating Systems older than Windows 2000.</p>

<p><a href='http://blog.nkadesign.com/wp-content/uploads/2008/05/transparentlayer02b.zip' title='Test database'><img src='http://blog.nkadesign.com/wp-content/uploads/2008/05/download.png' align="left" alt='Download' /></a>Download <a href='http://blog.nkadesign.com/wp-content/uploads/2008/05/transparentlayer02b.zip' title='Test database'>TransparentLayer02b.zip (138KB)</a>, recommended version<br />(improved, more flexible version, based on <a href="http://blogs.msdn.com/access/archive/2008/05/05/follow-up-to-transparency-forms.aspx">Rob&#8217;s updated article</a>).</p>

<p><a href='http://blog.nkadesign.com/wp-content/uploads/2008/05/transparentlayer01b.zip' title='Test database'><img src='http://blog.nkadesign.com/wp-content/uploads/2008/05/download.png' align="left" alt='Download' /></a>Download <a href='http://blog.nkadesign.com/wp-content/uploads/2008/05/transparentlayer01b.zip' title='Test database'>TransparentLayer01b.zip (122KB)</a>, original version<br />(simple code, based <a href="http://blogs.msdn.com/access/archive/2008/04/28/modal-dialogs-with-transparent-backgrounds.aspx">Rob&#8217;s original article</a>).</p>

<h3>Troubleshooting</h3>

<ul>
<li><em>If you are getting security warnings:</em> make sure that you open the database from a Trusted Location or you will receive a security prompt.
If you don&#8217;t know how to do that, <a href="http://office.microsoft.com/en-us/help/HA100319991033.aspx#11">check these steps</a>.</li>
<li><em>If the layer appears on top of the login form instead of behind:</em> make sure that the top-most form has ist <code>Modal </code>properties set to <code>Yes</code> and the <code>frmLightBox</code> form has its modal property set to <code>No</code>.<br />
If you improve on it, please let me know and I&#8217;ll post it here for all to find.</li>
</ul>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>A specific version for Access 2000 now included in the archive (updated 25JUL2008).&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2008/ms-access-modal-dialogs-with-transparent-backgrounds/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>WPF and Silverlight: it will take a while&#8230;</title>
		<link>http://blog.nkadesign.com/2008/wpf-and-silverlight-it-will-take-a-while/</link>
		<comments>http://blog.nkadesign.com/2008/wpf-and-silverlight-it-will-take-a-while/#comments</comments>
		<pubDate>Sun, 10 Feb 2008 08:45:07 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Musing]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/2008/wpf-and-silverlight-it-will-take-a-while/</guid>
		<description><![CDATA[Decoupling the User Interface from the underlying code has been one of the holy grails of application development. Layers of indirection and new patterns have been invented over time to try to separate what the user does from the back-end data. It&#8217;s been a long and difficult journey but WPF is the last attempt at [...]]]></description>
			<content:encoded><![CDATA[<p><img width="64" vspace="5" hspace="5" height="64" border="0" align="left" title="technology01.png" alt="technology01.png" src="/wp-content/uploads/technology01.png"/>Decoupling the User Interface from the underlying code has been one of the holy grails of application development.
Layers of indirection and new patterns have been invented over time to try to separate what the user does from the back-end data. It&#8217;s been a long and difficult journey but WPF is the last attempt at completely separating the user interface from the gut of an application, leaving graphic designer do what they do best and programmers do what they do best.<br />
I think this disconnect has actually hindered the adoption of WPF to a great extent.<br />
I also believe that Silverlight, while showing great promises, is going to take a long time to get off the ground.</p>

<p><img src='http://blog.nkadesign.com/wp-content/uploads/2008/02/silverlight1.png' alt='Silverlight' align="right" />Good graphic designers who work on User Interfaces are too few and far between, and large organisations will take time to get staff with a sufficient level of expertise to be useful in developing meaningful WPF/Silverlight applications.<br />
Until now, the bulk of the development effort was done by developers. Most ISV only have developers onboard.</p>

<p>As far as I can tell, it seems that main reason behind this slow adoption is that WPF/Silverlight has only been noticed by developers and they don&#8217;t know what to make with it.<br />
WPF/Silverlight are not really developer-friendly: the development infrastructure is there but we&#8217;re left with a blank canvas and nothing to drag and drop onto it.</p>

<p>There will be a great gap, probably lasting a few years, before there are enough experiments in these new user interfaces that some useful lowest common denominator can be exploited by non-designers.<br />
We&#8217;ll have to wait for tool vendors to provide the bulk of user interface blocks and for a few new patterns to appear before all the designer-challenged developers like me can make decent interfaces without requiring a professional graphic designer in their midst.<br />
In the mean time, we&#8217;ll probably have useless, but pretty, applications, some useful, but ugly ones and a lot of people scratching their head trying to couple the designers and the developers in a working relationship.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2008/wpf-and-silverlight-it-will-take-a-while/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MS SQL Server Express: a good choice?</title>
		<link>http://blog.nkadesign.com/2008/ms-sql-server-express-a-good-choice/</link>
		<comments>http://blog.nkadesign.com/2008/ms-sql-server-express-a-good-choice/#comments</comments>
		<pubDate>Wed, 30 Jan 2008 07:03:09 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/2008/ms-sql-server-express-a-good-choice/</guid>
		<description><![CDATA[Microsoft SQL Server comes in many editions, ranging from completely free to use and distribute to versions costing tens of thousands of dollars. For small businesses, or when you can live with the limits imposed, the Express edition is one option to consider. Here are some reasons why SQL Server Express may be a good [...]]]></description>
			<content:encoded><![CDATA[<p><img width="64" vspace="5" hspace="5" height="64" border="0" align="left" title="technology02.png" alt="technology02.png" src="/wp-content/uploads/technology02.png"/>Microsoft SQL Server comes in many editions, ranging from completely free to use and distribute to versions costing tens of thousands of dollars.<br />
For small businesses, or when you can live with the limits imposed, the Express edition is one option to consider.</p>

<p><img src='http://blog.nkadesign.com/wp-content/uploads/2008/01/sql_server_2005.gif' alt='SQL Server logo' style="float:right;margin-left:10px;margin-bottom:5px;" />Here are some reasons why SQL Server Express may be a good choice:</p>

<h3>You&#8217;re upsizing an Access database</h3>

<p>SQL Server is the natural extension of upsizing  an existing Access database. It work automagically with minimum effort providing that you followed some simple good-design rules from the start.</p>

<h3>You&#8217;re future-proofing your needs</h3>

<p>Because SQL Server comes in many flavours, you know you -or your customers- can upgrade to a more capable (albeit more expensive) version in the future if needed.</p>

<h3>Very flexible</h3>

<p>As usual with a lot of Microsoft development tools, SQL Server will happily let you shoot yourself in the foot by providing you with a fairly easy way to treat your database as a complete development platform.<br />
It&#8217;s good in the sense that you have interesting tools and capabilities included in the server, and it&#8217;s bad for the exact same reasons.<br />
I tend to prefer database servers to be just that: data repositories, and I&#8217;m not too fond of relying on specific, non-standard features of a particular database system, but what do I know.</p>

<h3>Excellent out-of-the-box development support</h3>

<p>Deep integration with .Net and Visual Studio, without any effort, Microsoft saw to that of course.<br />
In some cases, such as <a href="http://msdn2.microsoft.com/en-us/library/bb425822.aspx">LINQ to SQL</a>, it&#8217;s almost the only real choice, although the other database vendors are working hard at the necessary providers, so that lead should be short-lived.<br />
There is something to be said about developer productivity: you have to give credit to Microsoft for making their tools well integrated and usable from each-other. What it means is that for small developer shops there is much to gain in surrendering to this &#8220;ease of the default&#8221;.<br />
Of course, it&#8217;s a double-edged sword, but having a complete development infrastructure work out of the box is certainly a big help, and if you don&#8217;t like it, you&#8217;re still free to chose something else.</p>

<h3>Lots of tools</h3>

<p>With SQL Server Advanced Services, you also get Server Management and Reporting Services. These are great tools made available for free.<br />
The only missing one for SQL Server is the Reporting designer. While the reporting service means that you can use existing reports, only SQL Server Standard and Enterprise have it.<br />
There is an option for developers though: the (nearly free) SQL Server Developer edition is in fact the same as SQL Server Enterprise, without the license to use in non-developer or tester environment. This means that as a developer, you can create and distribute your reports to be used by your customers who will be using SQL Server Express.</p>

<h3>Did I mention it&#8217;s free?</h3>

<p><img src='http://blog.nkadesign.com/wp-content/uploads/2008/01/db_status.png' alt='db_status.png' style="float:right;margin-left:10px;margin-bottom:5px;" />All this is free, as in beer, not as in liberty though.<br />
For commercial applications targeted at small businesses, SQL Server Express is a really good choice: you can distribute it without problem, the customer gets all the tools, can easily find outside support, and they can always migrate to a more beefy version if their needs grow, all that without having to depend on you.<br />
So it sort of offers customers a <em>kind</em> of freedom that they wouldn&#8217;t have with other choices.</p>

<p>Of course you can get that with other database systems, although you have to be careful which Open Source one you choose: I recently decided not to use MySQL any longer for the simple reason that it&#8217;s too expensive and restrictive in a business environment, at least for the kind of work I do.</p>

<p>Why would you <em>not</em> want to use SQL Server Express?</p>

<h3>You don&#8217;t want to depend on Microsoft</h3>

<p>That can be a good reason enough sometimes. There is nothing preventing Microsoft from crippling SQL Server Express in the future to force users to move to a paying version early.<br />
I suppose that whatever database system you use, even Open Source ones, there is always the possibility that the company supporting its development goes bankrupt, the Open Source projects goes dead or decides to go in a direction that doesn&#8217;t suit you..</p>

<h3>It&#8217;s only supported on Microsoft OS</h3>

<p>True, and that&#8217;s a good reason to chose something else.<br />
There is a hidden cost in SQL Server Express: it needs to run on a Windows machine, and that&#8217;s not free, although SQL Server will work on older Windows 2000 machines and Windows XP which are arguably not expensive.</p>

<h3>Your database needs will exceed SQL Server Express specifications</h3>

<p>If you think any of your databases will grow beyond 4GB or that it will get busy and you need all the RAM and CPU you can get, then SQL Server Express is probably not for you as it will only use 1 CPU and 1GB of RAM at most.<br />
If your needs go beyond that, then you&#8217;ll have to move to a paying version.</p>

<h3>Upgrading can be expensive</h3>

<p>It&#8217;s true that moving to the next cheapest upgrade of SQL Server Workgroup will cost you about US$700 for a 5 user license. The limits imposed on the database are much higher (2 processors, 3GB RAM and no size limit) but if you need more clients / or higher limits, then the expense will grow quite fast, and you&#8217;ll have to manage those hateful client access licenses.</p>

<h3>Your needs are more modest</h3>

<p>We haven&#8217;t talked here about single-file/single-user database systems.
These databases don&#8217;t user resident services and are usually meant for more limited needs, sometimes allowing only a single user to be connected.<br />
The footprint of these non-server databases is a lot smaller, typically only requiring a single dll or a handful of files to be installed.<br />
They are extremely useful for desktop application that do not really require multi-user support or advanced security features.<br />
Here again, Microsoft offers SQL Server Compact, which, despite the name, doesn&#8217;t have much to do with the other SQL Server editions. This one is also free, but has a limited feature set and only allow single-user access as it is meant to be a lightweight database and works well in limited memory environments such as those found on mobile devices.<br />
<img src='http://blog.nkadesign.com/wp-content/uploads/2008/01/sqlite.gif' alt='SQLite logo' style="float:right;margin-left:10px;margin-bottom:5px;" />Of course, here again there is a lot of competition: Thunderbird, SQLite, MS Access and VistaDB (for embedding into .Net applications, not free) to name a few.</p>

<p>These are pretty good times when it comes to databases: we get more choices now than we ever had.<br />
As usual, choosing a database as a back-end for your products isn&#8217;t easy: you need to consider cost, licensing, support and the future.<br />
There isn&#8217;t a single database system that will meet everyone&#8217;s needs for all types of use, so choose carefully.<br />
SQL Server Express is a very good contender in that market. It should not be dismissed out of hand because it&#8217;s from Microsoft, in the same way that PostgreSQL shouldn&#8217;t be dismissed because it&#8217;s Open Source.<br />
Just use the tool that best answers your needs for your particular circumstances.</p>

<h3>References:</h3>

<ul>
<li>SQL Server Express main page<br />
<a href="http://www.microsoft.com/sql/editions/express/default.mspx">www.microsoft.com/sql/editions/express/</a></li>
<li>Compare SQL Server editions<br />
<a href="http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx">www.microsoft.com/sql/prodinfo/features/compare-features.mspx </a></li>
<li>System Requirements for SQL Server Express<br />
<a href="http://www.microsoft.com/sql/editions/express/sysreqs.mspx">www.microsoft.com/sql/editions/express/sysreqs.mspx</a></li>
<li>SQL Server Compact (single-user, small footprint database)<br />
<a href="http://www.microsoft.com/sql/editions/compact/default.mspx">www.microsoft.com/sql/editions/compact/</a></li></li>
<li>The VistaDB database, commercial embeddable database for .Net applications<br />
<a href="http://www.vistadb.net/">www.vistadb.net/</a></li>
<li>SQLite database, public domain, flexible file-database system<br />
<a href="http://www.sqlite.org/">www.sqlite.org/</a></li>
<li>The Firebird DB (based on <em>Interbase 6</em> from Borland)<br />
<a href="http://www.firebirdsql.org/">http://www.firebirdsql.org/</a></li>
<li>PostgreSQL Open Source database server<br />
<a href="http://www.postgresql.org/">http://www.postgresql.org/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2008/ms-sql-server-express-a-good-choice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>People, mind your dates&#8230; plz?</title>
		<link>http://blog.nkadesign.com/2007/people-mind-your-dates-plz/</link>
		<comments>http://blog.nkadesign.com/2007/people-mind-your-dates-plz/#comments</comments>
		<pubDate>Sat, 15 Dec 2007 15:34:46 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Musing]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/2007/people-mind-your-dates-plz/</guid>
		<description><![CDATA[What does 04/05/01 mean to you? Let&#8217;s make it easy: is that date in 2001 or 2004? And if I write it like 04/05/2001, is it really better? are we in April or May? And the answer is&#8230; If you are from North America and a handful other countries 04/05/01 would mean 5th of April [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/technology02.png" alt="technology02.png" title="technology02.png" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />What does 04/05/01 mean to you?<br />
Let&#8217;s make it easy: is that date in 2001 or 2004?<br />
And if I write it like 04/05/2001, is it really better? are we in April or May?<br />
And the answer is&#8230;</p>

<p><img src='/wp-content/uploads/2007/12/chcal.gif' alt='Chinese Calendar' style="float:right;margin-left:10px;margin-bottom:5px;" /> If you are from North America and a handful other countries 04/05/01 would mean 5th of April 2001.<br />
If you&#8217;re in Asia or some eastern countries, if could be 1st of May 2004.<br />
For the rest of the world, it would look like 4th of May 2001.</p>

<p>We cannot ignore any longer the importance of writing dates in a format that is understandable by everyone.<br />
Still too often, <a href="http://www.dnrtv.com/default.aspx?showNum=13">web sites</a> -even big <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=18b1d59d-f4d8-4213-8d17-2f6dde7d7aac&#038;DisplayLang=en">companies</a>- with a global audience state dates in a format that is probably obvious where they live but not consistently so to everyone else.</p>

<p>Developers are sometimes guilty of this sin, as can be seen in the format chosen to <a href="http://msdn2.microsoft.com/en-us/library/bb221200.aspx">specify dates in Microsoft Access SQL</a>, which requires that hard-coded dates be formatted in the US rather than the more neutral <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO8601</a> format.<br />
I wonder how many bugs that little egocentric feature caused in business applications that where <a href="http://www.vbforums.com/showthread.php?t=297258">developed by foreign coders</a>&#8230;<br />
I know it also happened to me at least once&#8230;</p>

<p><img src='/wp-content/uploads/2007/12/russcal.gif' alt='Russian Calendar' style='float:left;margin-right:10px;margin-bottom:5px;' />The worst thing is that when you write 04/05/06, you may very well have thought about the rest of the world and meant DD/MM/YY; alas, unless the context grants us some clarification or the actual date is unequivocal, there is sometimes no way for a lot of us to know for sure what you really meant.</p>

<p>We should ban the use of the short date format in communications that may be read by more than 3 people, in today&#8217;s world, that&#8217;s pretty much all communication.</p>

<p>Instead a simple format such as 05MAY2006 is clear an unequivocal: it&#8217;s easy to read and understand, regardless of where you live.<br />
You&#8217;re free to add spaces, dashes, dots, comas or slashes to it if you want, you can use 2006MAY05 if you prefer or even MAY05,2006, whatever pleases you: it still remains readable.</p>

<p>The rule is simple:<em>write the year in full and never write the month as a two-digit number, that&#8217;s reserved for the day</em></p>

<p>The point is that you, me and the rest of the world can read it and understand exactly what was meant; it&#8217;s an easy problem to solve.<br />
Surely that means something to you?</p>

<h3>References</h3>

<ul>
<li><a href="http://en.wikipedia.org/wiki/Date_format">http://en.wikipedia.org/wiki/Date_format</a></li>
<li><a href="http://www.moserware.com/2008/02/does-your-code-pass-turkey-test.html">Does you code pass the Turkey test?</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2007/people-mind-your-dates-plz/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>MediaWiki: Formating and colouring Code</title>
		<link>http://blog.nkadesign.com/2007/mediawiki-formating-and-colouring-code/</link>
		<comments>http://blog.nkadesign.com/2007/mediawiki-formating-and-colouring-code/#comments</comments>
		<pubDate>Tue, 20 Feb 2007 07:57:37 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=39</guid>
		<description><![CDATA[MediaWiki is the wiki software behind WikiPedia. The issue, when using it as a software development tool, is formatting code in a pretty way. As we did with WordPress before, here are some details to make dp.SyntaxHighlighter work fairly seamlessly with MediaWiki. Install the client-side highlighter Download dp.SyntaxHighlighter. Uncompress its content under a new /skins/common/SyntaxHighlighter [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/technology01.png" alt="technology01.png" title="technology01.png" align="left" width="64" height="64" hspace="5" vspace="5" border="0" /><a href="http://www.mediawiki.org">MediaWiki </a>is the wiki software behind <a href="http://www.wikipedia.org">WikiPedia</a>.<br />
The issue, when using it as a software development tool, is formatting code in a pretty way.
<a href="http://blog.nkadesign.com/?p=30">As we did with WordPress before</a>, here are some details to make <a href="http://www.dreamprojections.com/syntaxhighlighter/">dp.SyntaxHighlighter</a> work fairly seamlessly with MediaWiki.</p>

<h3>Install the client-side highlighter</h3>

<p>Download <a href="http://www.dreamprojections.com/syntaxhighlighter/">dp.SyntaxHighlighter</a>.
Uncompress its content under a new <code>/skins/common/SyntaxHighlighter</code> folder in your MediaWiki installation (don&#8217;t forget to make sure the files can be read by the web server; for instance, on Linux you may use <code>chown apache.apache -R *</code>).</p>

<p>In the skin template you are using for your MediaWiki site, insert the necessary code as required. In my example, I use the default <code>/skins/MonoBook.php</code> template into which I added the following:</p>

<p>Just before the closing <code>&lt;/head&gt;</code> tag:<br />
<textarea name="code" class="xml:nogutter:nocontrols">
<!-- http://www.dreamprojections.com/syntaxhighlighter/ -->
<link type="text/css" rel="stylesheet" href="/skins/common/SyntaxHighlighter/Styles/SyntaxHighlighter.css"></link></textarea>Just before the closing <code>&lt;/body&gt;</code> tag:<textarea name="code" class="xml:nogutter:nocontrols"><!-- http://www.dreamprojections.com/syntaxhighlighter/ -->
<script language="javascript" src="/skins/common/SyntaxHighlighter/Scripts/shCore.js"></script>
<script language="javascript" src="/skins/common/SyntaxHighlighter/Scripts/shBrushCSharp.js"></script>
<script language="javascript" src="/skins/common/SyntaxHighlighter/Scripts/shBrushXml.js"></script>
<script language="javascript" src="/skins/common/SyntaxHighlighter/Scripts/shBrushSql.js"></script>
<script language="javascript" src="/skins/common/SyntaxHighlighter/Scripts/shBrushJScript.js"></script>
<script language="javascript" src="/skins/common/SyntaxHighlighter/Scripts/shBrushPhp.js"></script>
<script language="javascript">
    dp.SyntaxHighlighter.HighlightAll('code');
</script></textarea></p>

<blockquote>
  <p><em>Note that you must include a reference to each source file corresponding to the type of programming language you want to highlight.<br />
  Have a look under the <code>/skins/common/SyntaxHighlighter/Scripts/</code> folder to see which languages you can highlight; there are a lot more than the few I use on my site.</em></p>
</blockquote>

<h3>Install the WikiMedia extension</h3>

<p>I&#8217;ve created a small extension to WikiMedia to allow us to enclose any source code in a new <code>&lt;codesyntax&gt;</code> tag.
Click on the <em>View Plain</em> option below and copy-paste the following code into a new file that you will save under <code>/extensions/syntaxhighlighter.php</code> (again, make sure this is readable by the webserver).<br />
<textarea name="code" class="php:nogutter">&lt;?php
/************************************************************
** Simple WikiMedia extension to create a new &lt;codesyntax&gt; tag that renders 
** syntax highlighted through the dp.SyntaxHighlighter javascript helper
** See http://www.dreamprojections.com/syntaxhighlighter/
** See http://meta.wikimedia.org/wiki/Extending_wiki_markup
** (c) Renaud Bompuis, 2007
** ------------------------------------------------------------------------------
** v1.0 - 20EFB2007 : first version. Uses the &lt;pre&gt; tag to ensure that the content of 
** the &lt;textarea&gt; containing the source code will not be messed up by WikiMedia.
** There are certainly better ways to do this, but they seem more complicated than this 
** (registering hooks, recording content before it is expanded and then replacing 
**  messed up content with the original)
************************************************************/
$wgExtensionFunctions[] = "wfSyntaxHighlighterExtension";

function wfSyntaxHighlighterExtension() {
    global $wgParser;
    $wgParser->setHook( "codesyntax", "renderCodeSyntax" );
}

// The callback function for converting the input text to HTML output
function renderCodeSyntax( $input, $argv, &$parser ) {
	$output = "&lt;pre style='border:0;padding:0;margin:0;'&gt;"
			  ."&lt;textarea name='code' class='".$argv["lang"]."'&gt;"
			  .Xml::escapeTagsOnly($input)
			  ."&lt;/textarea&gt;&lt;/pre&gt;" ;
    return $output;
}
?&gt;</textarea><br />
Add the following line to the end of your <code>LocalSettings.php</code> file, right before the closing <code>?&gt;</code> tag.<br />
<textarea name="code" class="php:nogutter:nocontrols">
require_once 'extensions/syntaxhighlighter.php';
</textarea></p>

<h3>Usage</h3>

<p>To highlight code in your MediaWiki pages, just enclose your source code with the new <code>&lt;codesyntax&gt;</code> tag. This tag takes a <code>lang</code> attribute to specify the options that normally would be listed in the <code>class</code> attribute in the <em>dp.SyntaxHighlighter</em> documentation.</p>

<p>For example:<br />
<textarea name="code" class="php:nogutter:nocontrols">
&lt;codesyntax lang="c#"&gt;
string url = "&lt;a href=\"" + someObj.getUrl() + "\" target=\"_blank\"&gtl;";
// single line comments
// second single line
override protected void OnLoad(EventArgs e)
{
	if(Attributes["class"] != null)
	{
		//_year.CssClass = Attributes["class"];
	}
//	base.OnLoad(e);
}
&lt;/codesyntax&gt;
</textarea><br />
Will display as:<br />
<textarea name="code" class="c#">string url = "&lt;a href=\"" + someObj.getUrl() + "\" target=\"_blank\"&gt;";
// single line comments
// second single line
override protected void OnLoad(EventArgs e)
{
	if(Attributes["class"] != null)
	{
		//_year.CssClass = Attributes["class"];
	}
//	base.OnLoad(e);
}
</textarea></p>

<p>For more information on using <em>dp.SyntaxHighlighter</em> see:<br />
<a href="http://www.dreamprojections.com/syntaxhighlighter/Usage.aspx">http://www.dreamprojections.com/syntaxhighlighter/Usage.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2007/mediawiki-formating-and-colouring-code/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Chosing a development platform</title>
		<link>http://blog.nkadesign.com/2006/chosing-a-development-platform/</link>
		<comments>http://blog.nkadesign.com/2006/chosing-a-development-platform/#comments</comments>
		<pubDate>Sun, 01 Oct 2006 08:39:54 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Musing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=33</guid>
		<description><![CDATA[LAMP, Zend, .Net, Struts, Ruby on Rails, Catalyst, and a hundred other development platforms all compete for you attention, all pretending to be the only thing you&#8217;ll ever need to satisfy your every needs in web or UI development. Making a decision is really hard: you want the best for your new project and want [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/technology02.png" alt="technology02.png" title="technology02.png" align="left" width="64" height="64" hspace="5" vspace="5" border="0" /><a href="http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29">LAMP</a>, Zend, .Net, <a href="http://struts.apache.org/">Struts</a>, <a href="http://www.rubyonrails.org/">Ruby on Rails</a>, <a href="http://www.catalystframework.org/">Catalyst</a>, and a hundred other development platforms all compete for you attention, all pretending to be the only thing you&#8217;ll ever need to satisfy your every needs in web or UI development.<br />
Making a decision is really hard: you want the best for your new project and want to make the right decision. In most cases, that means not cursing yourself down the line for a choice that didn&#8217;t turn out as expected.</p>

<p>When you start looking into all these platforms you can be blown away by the ease of implementation and elegance of some; your head spins at all the features and claims being made and it becomes hard to achieve a rational decision.</p>

<p>I&#8217;ve been faced with that very issue recently and it sucks. Actually, the time spent investigating all these possibilities is really what is being sucked away.<br />
Of course, learning about new technologies is not just fun, it&#8217;s also essential: you have to keep on top of what&#8217;s new and decide if you want to join in on the fun or just stay comfortably where you are.</p>

<p>I also realized that you need to get away from the coolness factor of each these much touted technologies and actually <em>try</em> to be objective.<br />
During my investigation, I tried to decide what were the really important factors that I should consider to make a rational choice.</p>

<p>I came up with the list of the following 10 questions that I think everyone should ask themselves when choosing a platform for an important project.</p>

<h3>1- Is the platform wide enough?</h3>

<p>New technologies that can show amazing productivity get all the buzz. After all, that&#8217;s what we developer want: enough with the nuts &amp; bolts! Give us a toolbox with all new shinny power tools!
The problem is that often these technologies are impressive, but looking beyond the sample projects into what actual users get confronted to, you start noticing discussion threads that should obviously signal that the platform is not wide enough.<br />
Choosing a technology that hasn&#8217;t achieved its goals can be a huge problem down the line: you implement 80% of your project in record time, only to realise that the platform you chose doesn&#8217;t support proper cross-browser detection, or that its implementation of security is way too lax, or that it only support XML for data storage and now you actually need a real database for performance reasons&#8230;<br />
In those cases, you can of course develop those areas yourself and contribute to the project, but doing so supposes that you planed it all along and you factored that in your schedule, both in time and in cost.</p>

<h3>2- Is it popular?</h3>

<p>In other words: are other professional people actually using that platform in real life?
I&#8217;m not talking about Joe Developer using it for his local community church website. I&#8217;m talking about businesses or large organisations actually using that software platform successfully.<br />
If all you need is a simple 3 page website, then professional popularity amongst the Top 500 business companies is probably not that important. On the other hand, if you plan to build a large project, or you know that your project could grow large in the future, then you probably want to ensure that others have taken it there before you.</p>

<h3>3- Is it mature?</h3>

<p>Has the platform existed for long enough that it went through enough abuse to withstand almost anything you can throw at it?<br />
A technology that is only a couple year old may be too young to have evolved to the point where it actually can solve most common and not-so-common problems. Technology evolves through iterations: each one is a good long hard look at what didn&#8217;t work and tries to fix, improve and extend.<br />
A young technology may be more cutting-edge and exciting, but when you need to commit to it for a big project, its age may quickly come as an issue; its shinny surface may blind you to the black holes waiting below&#8230;</p>

<h3>4- Are local developers available?</h3>

<p>Always think about the future. When you&#8217;re gone from the project, who is going to look after it?
Getting a web project entirely in <a href="href=&quot;http://www.rebol.com/">Rebol</a> may be cool and fun, but how many people in your city actually use that thing anyway?<br />
Aren&#8217;t you creating a liability if you&#8217;re dead-set on choosing a platform that cannot be maintained?</p>

<h3>5- Is it scalable?</h3>

<p>Most projects start small but dream of ending-up big.<br />
It&#8217;s usually fine at the beginning when the number of users and visitors is manageable, but what happens when you start to be successful?<br />
After all, that&#8217;s why we craft our projects: we want them to succeed, we want the world to see them. When the world starts coming though, will the terrific platform we&#8217;ve chosen break at the seams?<br />
How much overhead does the platform create? It is flexible in its database support? Is there a way to implement clustering or persisting sessions accross multiple servers?<br />
What&#8217;s the cost in memory and CPU resources? How many simultaneous connections can you get?   What are the bottlenecks? What do you need to do to compensate for them? How much would it cost?</p>

<h3>6- Do you have control?</h3>

<p>Some frameworks work hard for you and can make you really productive. Sometime though, they try too hard and hide too much from you.<br />
When a feature doesn&#8217;t exactly work the way you want you have to dig deep into the entrails of the beast to make sense of it and change its behaviour.<br />
A platform that was all nice and pretty can get very dirty and complex inside, making it difficult to adapt to your needs.<br />
A platform should do most of the hard work but still allow you to redefine its default behaviour without much hassle. It should be built with extensibility in mind, making easy thing easy and difficult things possible.<br />
A case in point are <a href="http://en.wikipedia.org/wiki/Fourth-generation_programming_language">4G</a> development platforms: they usually have a fairly narrow field of expertise and tend to use graphics and nice simple paradigms to quickly build complex tasks but when you are faced with a specific issue that hasn&#8217;t been solved by the platform, you often have to resort to ugly hacks to get around their limitations.</p>

<h3>7- Does it satisfies the essential constraints for your project?</h3>

<p>When being blinded by something cool, we often become skewed in our judgement and guilty of lowering the importance of constraints that are actually critical for our project.<br />
In all honesty, I really wanted to use Ruby on Rail, and I liked the principle and elegance of it so much that I came to seriously consider it, that is, until I came to my senses and looked into something that is critical to my project: support for complex Asian languages.<br />
Ruby is being developed in Japan, so you could think that it should be able to handle complex ideographic characters well.<br />
Turns out that the Japanese are not terribly fond of Unicode and, unless I&#8217;m mistaken, prefer to use <a href="http://en.wikipedia.org/wiki/Code_page">Code Pages</a> instead. The result is that Ruby doesn&#8217;t have great support for Unicode, and that sucks.<br />
That&#8217;s why Unicode was created: to attempt to simplify all this patchwork of implementations that are not compatible with each other.<br />
Because I needed to be able to handle English, Mandarin, Cantonese and probably any other language out there, Unicode is the only viable option to abstract the issue of language enough that it becomes manageable.<br />
So because of Ruby&#8217;s poor support for Unicode, it would not be rational to use Ruby on Rails for my particular project as it would probably greatly increase the complexity and hacks necessary to manage complex Asian languages in a unified and simple way.</p>

<h3>8- Documentation?</h3>

<p>All framework have a more or less steep learning curve: you need to think differently to adapt to the particular framework&#8217;s frame of mind, so to speak.<br />
Make sure that the framework has a lively community, that it has more documentation than you can swallow and that documentation is well organised.<br />
Make sure also that there are samples, tutorials, webcasts, videos or whatever that cover the principle aspects of it.<br />
A beautiful framework no-one talks about means that no-one will answer when you have a question. A beautiful framework without documentation is useless. A beautiful framework with lots of disorganised docs means that you&#8217;re going to waste a lot of time experimenting instead of building your project.</p>

<h3>9- Support?</h3>

<p>Here I mean support in the wide sense of the word: who is behind the framework. Are they likely to stay in business long after your project has been completed?<br />
Are they commercial or Open Source? In either case there are issues for and against: a commercial venture backed by a small company may falter and disappear overnight. Similarly, an exciting open source project managed by only 2 people can suffer the same fate when they decide to move on. 
Support also includes what help is available to you when you encounter issues. Is there any guarantee that you could have your important technical questions answered?<br />
If you encounter a large issue, is there someone to help you?<br />
I would contend that the best and most serious projects should have professional help available: you can always fall back on paying someone to help you through, whether it&#8217;s the original developers, a paid-for support hotline or a third-party specialist, it&#8217;s important that you know you can get your answers when you&#8217;re stuck.<br />
Developing for an important project without safety net is dangerous: you can waste a lot of time and effort, endangering the very project you are undertaking, if you stumble on a problem you cannot solve yourself.<br />
Large frameworks like .Net or big Open Source projects usually have enough users and support groups and specialists that it&#8217;s likely any question you may have has already been answered somewhere or that you can pay someone to help you out when you need it most.</p>

<h3>10- What do you know best?</h3>

<p>Every framework is based around a particular data-management model. Every framework is built with a particular programming language in mind. Every framework demands that you learn something new.
How comfortable are you with the requirements? how long is it going to take you to start to get really productive?<br />
Like their real-world counterpart, it can take very little time to learn a new language&#8217;s words and syntax but it takes years to become proficient in it. A framework adds another layer of abstraction that you will need to get experienced at.<br />
If you need to both learn a new language and a new framework, chances are that you are at best months away from being able to churn code without having to look into the documentation every 5 minutes.<br />
Learning new languages and concepts is necessary, but again, if you chose that route you must be sure that your project has that learning curve built-in, otherwise you&#8217;re going to move at the pace of a turtle when in fact you chose that particular framework because you though you would be more productive and faster than a sparrow.<br />
If you chose a new framework, make sure that you already possess most of the knowledge it requires: in my particular instance, I chose .Net and C# because I have already worked in that framework and I know it can tackle the project without me having to waste too much time on learning the platform rather than implementing the project.</p>

<p>We all should seize any opportunity to learn something new. Learning is often more exciting than doing the same old thing over and over again and it&#8217;s a necessary part of staying in business. Curiosity is an excellent quality that must be nurtured and indulged.<br />
The issue is <em>when</em> to do it.</p>

<p>Choosing a new development framework is not easy. The best way to tackle the problem is to pose it as a <em>risk analysis</em> study.</p>

<p>The framework you chose should simply be the one that poses the least risk to you succeeding your project.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2006/chosing-a-development-platform/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Software: Cheap Microsoft Licenses</title>
		<link>http://blog.nkadesign.com/2006/software-cheap-microsoft-licenses/</link>
		<comments>http://blog.nkadesign.com/2006/software-cheap-microsoft-licenses/#comments</comments>
		<pubDate>Mon, 18 Sep 2006 14:31:13 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=32</guid>
		<description><![CDATA[I&#8217;m not particularly pro -Microsoft but I&#8217;m not against it either. I love Linux, got my RHCE (Red Hat Certified Engineer) a bit more than a year ago and I love Open Source, Linux and all things GNU. The only thing I really dislike about Microsoft is its marketing, its pricing, its Genuine (Dis)Advantage that [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/money01.png" alt="Business" title="Business" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />I&#8217;m not particularly pro -Microsoft but I&#8217;m not against it either.<br />
I love Linux, got my <a href="http://etc.nkadesign.com/Linux/RedHatCertifications">RHCE</a> (Red Hat Certified Engineer) a bit more than a year ago and I love Open Source, Linux and all things <a href="http://gnu.org/">GNU</a>.</p>

<p>The only thing I really dislike about Microsoft is its marketing, its pricing, its <a href="http://www.securityfocus.com/columnists/409">Genuine (Dis)Advantage</a> that nags me every time I need to install something and its lack of openness when it comes to inter-operability with other competing implementations (here I&#8217;m particularly thinking about its network protocols that the <a href="http://samba.org/">Samba</a> team tries to decipher and re-implement as an Open Source platform).<br />
On the other hand, Microsoft is made of great programmers, great minds that you can watch on <a href="http://channel9.msdn.com/">Channel 9</a> and read on their insightful <a href="http://blogs.msdn.com/Bloggers.aspx">blogs</a>.</p>

<p>Microsoft is really (I mean REALLY) <a href="http://youtube.com/results?search_query=ballmer+developer">pro-developer</a>: they understand that the Operating System alone is nothing without lots of applications sitting on top of it, and they offer developers a lot of goodies.<br />
One such useful programme is +Microsoft Empower for ISV_. It&#8217;s a simple membership that allows a small software company (ISV meaning <em>Independent Software Developer</em>) to own a number of licenses for its internal use at a fraction of the price it would normally cost.<br />
What you get is pretty wide for a small business: 5 licenses for Windows XP (whatever version), 5 licenses for Microsoft Office, 1 license for Windows 2003 Server and Exchange, SQL Server, SharePoint Portal, a MSDN Premium Subscription that covers almost anything else, including 5 licenses for Visual Studio 2005 Pro.<br />
You also get access to MSDN downloads, beta software and tons of libraries, SDK, etc.
A MSDN subscription alone is about US$2000&#8230;<br />
The Empower ISV programme is quite cheap and depend on the country you are in.<br />
I paid mine HK$4,260 about US$530.</p>

<p>To get all this you need to register as a <a href="http://partner.microsoft.com/">Microsoft Partner</a> (that&#8217;s free), then apply for the <a href="https://partner.microsoft.com/global/40011351">Empower for ISV programme</a> by making a promise to release a commercial software within 2 year at most. You need to give some details and pay your due. After a few days, you get confirmation if your application is accepted or not.<br />
As far as I know, you need to be a company and have a company website, but that may not be mandatory in all regions.<br />
The software you get is the normal US version plus whatever local version there are for your region. My bunch of DVD came in Japanese, Cantonese, Mandarin, some in Korea and Thai too.<br />
At least, the English version is supplied. For some software, you also get the multilingual version that include European languages as well.<br />
You manage your licenses by login under your MSDN account.</p>

<p>Really, it&#8217;s a nice touch from Microsoft to give us poor developers access to all this for such a reasonable price. I can only encourage other small software companies and independent developers to do the same.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2006/software-cheap-microsoft-licenses/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.Net: The limits of using Reflection</title>
		<link>http://blog.nkadesign.com/2006/net-the-limits-of-using-reflection/</link>
		<comments>http://blog.nkadesign.com/2006/net-the-limits-of-using-reflection/#comments</comments>
		<pubDate>Tue, 13 Jun 2006 00:00:27 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=29</guid>
		<description><![CDATA[Reflection is a hugely useful technology: it allows you to get inside objects and get their intimate details, modify their values and even rewrite part of their code. Today I wanted to build a simple treeview control that would display the hierarchical structure of an arbitrary object by going through its properties and building a [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/technology02.png" alt="technology02.png" title="technology02.png" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />Reflection is a hugely useful technology: it allows you to get inside objects and get their intimate details, modify their values and even rewrite part of their code.<br />
Today I wanted to build a simple treeview control that would display the hierarchical structure of an arbitrary object by going through its properties and building a tree-like structure. Useful to visualise the internals of an object and see changes at runtime.</p>

<p>Using PropertyInfo you get enough information about a particular property to decide if you want to display it or recurse into it if it&#8217;s a complex type that contain other properties.</p>

<p>The only big issue I faced was when dealing with <a href="http://msdn2.microsoft.com/en-us/6x16t2tx.aspx">indexers</a>.</p>

<h3>The issue with Indexers</h3>

<p>Indexers are defined in code like that:<br />
<textarea name="code" class="c#:nogutter:nocontrols" cols="50" rows="10">
using System;
using System.Collections;

public class DayPlanner
{
    // We store our indexer values in here 
    Hashtable _meetings = new System.Collections.Hashtable();

    // First indexer
    public string this[DateTime date] {
        get {
            return _meetings[date] as string;
        }
        set {
            _meetings[date] = value;
        }
    }

    // Second indexer, overloads the first
    public string this[string datestr] {
        get {
            return this[DateTime.Parse(datestr)] as string; 
        }
        set {
            this[DateTime.Parse(datestr)] = value;
        }
    }
}
</textarea>We&#8217;ve defined an overloaded indexer: one takes a <code>DateTime</code>, the other just a string representation of a date.</p>

<p>We could use them like that for instance:<br />
<textarea name="code" class="c#:nogutter:nocontrols" cols="50" rows="10">
DayPlanner myDay = new DayPlanner();
myDay[DateTime.Parse("2006/02/03")] = "Lunch";
...
string whatNow = myDay["2006/06/26"]; 
</textarea>
Now, let&#8217;s say we want to print all property names and their values for an arbitrary object.<br />
Let&#8217;s try on our <code>myDay</code> intance:<br />
<textarea name="code" class="c#:nocontrols" cols="50" rows="10">
Type type = myDay.GetType();
PropertyInfo[] picoll;
picoll = type.GetProperties( BindingFlags.Public 
          | BindingFlags.Instance | BindingFlags.Static);

foreach (PropertyInfo pi in picoll) {
    object val;
    val = pi.GetValue(myDay, null);
    Debug.WriteLine(pi.Name+"="+val) );
}
</textarea>So, that part is easy: we iterate through all properties of <code>myDay</code> and print their <code>Name</code> and they value.<br />
Problem is, when we reach the indexer property, we get a <code>TargetParameterCountException</code> on line&nbsp;8.</p>

<p>We need to detect the indexer before attempting to get its value.<br />
To do that, we need to modify our <code>foreach</code> loop to:<br />
<textarea name="code" class="c#:nocontrols"  cols="50" rows="10">
foreach (PropertyInfo pi in picoll) {
    object val;
    ParameterInfo[] parcoll = pi.GetIndexParameters();
    if (parcoll.Length == 0) {
        val = pi.GetValue(o, null);
        Debug.WriteLine(pi.Name+"="+val) );
    }
}
</textarea>
Here we attempt to get the indexer parameters for every property. If we&#8217;re dealing with an indexer, the <code>parcoll</code> array will contain a list of <code>ParameterInfo</code> related to that particular indexer.</p>

<p>So what really is this <code>parcoll</code> and its <code>ParameterInfo</code>s?</p>

<p>A <code>ParameterInfo</code> contain information about the parameter of an indexer property.<br />
The <code>parcoll</code> array will contain one entry for each overloaded indexer.<br />
In our concrete example this is what we get:</p>

<ul>
<li><code>pi.Name</code> will be <em>Items</em>, this is standard for all indexer properties.</li>
<li><code>pi.PropertyType</code> is the type of the returned class of our indexer, in our case, a <em>System.String</em>.</li>
<li><code>parcoll.Length</code> will be equal to 2 because we have 2 overloaded indexers.</li>
<li><code>parcoll[0].Name</code> will be <em>date</em>.</li>
<li><code>parcoll[1].Name</code> will be <em>datestr</em>.</li>
<li><code>parcoll[0].ParameterType</code> will be <em>System.DateTime</em>.</li>
<li><code>parcoll[1].ParameterType</code> <em>System.String</em>.</li>
<li><code>parcoll[0].Member</code> and <code>parcoll[1].Member</code> are in fact references to <code>pi</code> itself</li>
</ul>

<p>That&#8217;s a lot of nice information about our indexer, but what if we want to get a value from it?
Consider the definition for <code>GetValue</code>:<br />
<textarea name="code" class="c#:nogutter:nocontrols"  cols="50" rows="10">
PropertyInfo.GetValue(object o, object[]{} index).
</textarea>
That second parameter is used to get a value from the indexer.</p>

<h3>So, how do we use it?</h3>

<p>If you know valid keys that you can feed to the indexer, then you just do that (assuming that <code>pi</code> is the <code>PropertyInfo</code> for the indexer).<br />
<textarea name="code" class="c#:nogutter:nocontrols"  cols="50" rows="10">
string meeting;
meeting = pi.GetValue(myDay, new string[]{"2006/02/25"}) as string;
</textarea>
Or, if you prefer to use a <code>DateTime</code>:
<textarea name="code" class="c#:nogutter:nocontrols"  cols="50" rows="10">
string meeting;
meeting = pi.GetValue(myDay, new DateTime[]{DateTime.Now}) as string;
</textarea>
But what if you don&#8217;t know anything about the values contained by the indexer?<br />
Well, unless you use attributes to decorate the indexer or the underlying storage field with specific custom information, you&#8217;re basically screwed.</p>

<p>To understand why, just consider how the indexer is implemented:<br />
When you pass it a <code>DateTime</code> or a <code>string</code> as a parameter, it just passes it on to the getter/setter as the <code>value</code>.<br />
What is done with that is up to the implementer.<br />
If you want to maintain a collection of some kind, then you need to use private fields to hold the keys and their values.<br />
.Net doesn&#8217;t store the values passed to the indexer or the values returned by it anywhere.</p>

<p>Consider how .Net doesn&#8217;t give you any means of iterating through the keys and values of an indexer.<br />
You can&#8217;t do a <code>for(;;)</code> or a <code>foreach()</code> loop, you can&#8217;t even know how many items are maintained through the indexer by directly questioning it.<br />
So, it certainly is normal that you cannot get anything out of the indexer without knowing exactly how to access it.</p>

<h3>The Observer Effect</h3>

<p>In many fields of science, the act of measuring something, whether it&#8217;s an electronic circuit or a psychological experiment, can actually influence the observed phenomenon.<br />
This is unsurprisingly called the <a href="http://en.wikipedia.org/wiki/Observer_effect">Observer Effect</a>.</p>

<p>In .Net, Reflecting on object can be very much the same.</p>

<p>Consider the use of Reflection when it comes to getting information about an object:<br />
You use metadata describing the object to get more meta data information about its members
You can use that meta data to direcly query the state of an object.</p>

<p>If you limit yourself to getting metada, then no harm is done: you&#8217;re not querying the object instance itself but the metadata about its class.</p>

<p>If you start querying an actual object instance for its values then you are actively interacting with it.<br />
In most cases, if you&#8217;re just getting the value of Fields or Properties defined as follow, then it&#8217;s fine:<br />
<textarea name="code" class="c#:nogutter:nocontrols"  cols="50" rows="10">
class GetMe {
    private string _meeting;
    public string Meeting {
        get { return _meeting; }
        set {
            _meeting = value;
        }
    }
}</textarea>
Using reflection, we can get the values of both <code>_meeting</code> and <code>Meeting</code> without any side-effect to the object.</p>

<p>Now consider this:<br />
<textarea name="code" class="c#:nogutter:nocontrols"  cols="50" rows="10">
class GetMeNot {
    private int _collection = null;
    public int Collection {
        get { 
            if ( _collection == null ) {
                OpenDatabaseConnection();
                _collection = FetchAllData();
            }
            return _collection; 
        }
    }
}</textarea>
Now what we&#8217;ve got here is a case of lazy loading or <a href="http://en.wikipedia.org/wiki/Lazy_initialization">lazy initialization</a>.<br />
The consequence is that by querying the Collection property we&#8217;re actually creating it, with a potential for a lot of side-effects, like the change of other properties, here maybe related to opening the database connection for instance.</p>

<p>So, when getting values of the properties of an object instance, we can actually completely change its state.<br />
Whether this is a concern or not really depends on what you&#8217;re trying to achieve: you may not be able to achieve being a passive observer using Reflection unless you know about the construction of the particular class you&#8217;re dealing with.<br />
Using Attributes, you could give hints about which Property not to query and which Field to get instead. In our case, we could add a custom attribute like <code>[ImplementedBy("_collection")]</code> to our <code>Collection</code> property for instance.</p>

<p>If you want to do something generic, then you&#8217;re out of luck it and have to deal with that fact.<br />
One possible way to minimize the effect would be to not query Properties that only have a getter and no setter, but that&#8217;s not a guarantee that all properties that implement a getter/setter are going to play nice.<br />
Then there is also the -probably rarer- case of the Property that only has a setter.<br />
Then there is also the case of the property getter that has some in-build security and will return different things depending on who&#8217;s calling&#8230;</p>

<p>All this seems pretty obvious once you understand the whole picture but it&#8217;s easy to get so impressed and dazzled by the power of Reflection that you don&#8217;t realise its natural limits.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2006/net-the-limits-of-using-reflection/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>XPO: eXpress Persistent Objects</title>
		<link>http://blog.nkadesign.com/2006/xpo-express-persistent-objects/</link>
		<comments>http://blog.nkadesign.com/2006/xpo-express-persistent-objects/#comments</comments>
		<pubDate>Fri, 09 Jun 2006 04:00:31 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XPO]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=28</guid>
		<description><![CDATA[<img src="/wp-content/uploads/technology02.png" alt="technology02.png" title="technology02.png" align="left" width="64" height="64" hspace="5" vspace="5" border="0" /><a href="http://www.devexpress.com/Products/NET/XPO/">XPO </a>is an Object Relational Mapping .Net product from <a href="http://www.devexpress.com">Developer Express</a>, a cool company designing cool tools.
It's a programming component whose job is to abstract access to database while allowing the developer to concentrate on a simple object-oriented interface instead.]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/technology02.png" alt="technology02.png" title="technology02.png" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />
<a href="http://www.devexpress.com/Products/NET/XPO/">XPO</a> is an Object Relational Mapping .Net product from <a href="http://www.devexpress.com">Developer Express</a>, a cool company designing cool tools.<br />
It&#8217;s a programming component whose job is to abstract access to database while allowing the developer to concentrate on a simple object-oriented interface instead.<br />
<span id="more-28"></span></p>

<p>There is an impedance mismatch between the usual programming technology and the database worlds. 
The mismatch occurs because most development is object-oriented and most database systems are query-based.<br />
Getting data from the database into your objects and back is tricky and difficult to maintain: any modification in either camp needs to be reflected to the other.</p>

<p>One solution is to use an intermediate layer to take care of the impedance mismatch for us: that&#8217;s the job of he ORM.</p>

<p>When I initially took the decision to use an ORM I tried and reviewed a few. Each have a different way of doing their job and place emphasis on different things, depending on the school of thought they belong to.<br />
Most still require a database-centric view and either abstract the whole and let you deal with meta-data that used to modify both code and database or they just let you modify the database and then update automatically the code.<br />
Then there was XPO.<br />
This one was a bit different: it really completely abstracted the database. It would create and update it automatically (whenever possible) without you having to ever deal with how the data is stored: it would work in the exact same way regardless of the underlying chosen database.<br />
You could even use it on an already existing database and it would be happy to talk to it.</p>

<p>So I chose XPO.<br />
It didn&#8217;t have fancy designers but it offers a simple, reliable and flexible way to persist my objects in the database of my choosing.<br />
One thing to note too is that you can get it with full source code (not commented though).<br />
I find it reassuring when a company doesn&#8217;t mind its code to be scrutinised by its customers. It&#8217;s also proven invaluable in finding out XPO&#8217;s inner working (not that I understand a lot though).</p>

<p>I&#8217;ll be blogging a few articles in the future on various aspects of XPO that I think may be of interest to those already working with it. I&#8217;m not going to re-state what&#8217;s in the documentation or on the Developer Express (DX) community website and official pages, there is a lot of information available out there, it&#8217;s just sometimes hard to get to know the fundamentals because it&#8217;s sometime buried deep.
Whenever possible (depending on time and complexity) I&#8217;ll make a sample project. I&#8217;m even thinking about building a repository of samples showcasing various aspects of XPO.</p>

<p>Let&#8217;s see if I can hold the load for long&#8230;. I&#8217;ve also committed myself to DXCore recently&#8230; but that&#8217;s something for another post altogether&#8230;</p>

<h3>References:</h3>

<ul>
<li>Official XPO product page<br />
<a href="http://www.devexpress.com/Products/NET/XPO/">http://www.devexpress.com/Products/NET/XPO/</a></li>
<li>XPO articles on the DX Community blog<br />
<a href="http://community.devexpress.com/blogs/xpo/">http://community.devexpress.com/blogs/xpo/</a></li>
<li>DX Peer Support newsgroups<br />
<a href="http://www.devexpress.com/Support/Newsgroups.xml">http://www.devexpress.com/Support/Newsgroups.xml</a></li>
<li>DX Knowledge base articles<br />
<a href="http://devexpress.com/Support/KnowledgeBase/">http://devexpress.com/Support/KnowledgeBase/</a></li>
<li>DX Support center where additional information, tips and bug reports can be found.<br />
<a href="https://www.devexpress.com/support/center/">https://www.devexpress.com/support/center/</a></li>
<li>An extensive list and description of available ORM for .Net<br />
<a href="http://www.howtoselectguides.com/dotnet/ormapping/">http://www.howtoselectguides.com/dotnet/ormapping/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2006/xpo-express-persistent-objects/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>You Aren&#8217;t Gonna Need It</title>
		<link>http://blog.nkadesign.com/2006/you-arent-gonna-need-it/</link>
		<comments>http://blog.nkadesign.com/2006/you-arent-gonna-need-it/#comments</comments>
		<pubDate>Thu, 01 Jun 2006 01:00:03 +0000</pubDate>
		<dc:creator>Renaud Bompuis</dc:creator>
				<category><![CDATA[Musing]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.nkadesign.com/?p=14</guid>
		<description><![CDATA[<img src="/wp-content/uploads/technology02.png" alt="technology02.png" title="technology02.png" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />Refactoring code is a necessary thing. Unless you work in some very specific environment where casual refactoring is not allowed (like in some safety-critical applications where the most minute change has to be pondered upon by teams and committees for weeks), you cannot code perfectly on the first shot.
More often, you end-up reviewing code and making it clearer, merging parts that are too similar, removing what turned out not to be useful, cleaning up the names, moving things around, etc... there are dozen of refactoring cases that usually help <a href="http://www.codinghorror.com/blog/archives/000589.html" target="_blank">remove the stink out of it</a>.]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/technology02.png" alt="technology02.png" title="technology02.png" align="left" width="64" height="64" hspace="5" vspace="5" border="0" />
Refactoring code is a necessary thing. Unless you work in some very specific environment where casual refactoring is not allowed (like in some safety-critical applications where the most minute change has to be pondered upon by teams and committees for weeks), you cannot code perfectly on the first shot.<br />
More often, you end-up reviewing code and making it clearer, merging parts that are too similar, removing what turned out not to be useful, cleaning up the names, moving things around, etc&#8230; there are dozen of refactoring cases that usually help <a href="http://www.codinghorror.com/blog/archives/000589.html">remove the stink out of it</a>.
<span id="more-14"></span></p>

<p>One self-inflicting problem I&#8217;ve often been confronted to is <em>over-engineering</em>: I tend to <em>over-think</em>, <em>over-design</em> and <em>over-anticipate</em>.<br />
Sometimes it&#8217;s good to just spend time trying to make your code more modular and as future-proof as you can, but often, it leads to code that has no real use <em>right-now</em>, and that ends up having to be modified because when you need it, it&#8217;s not in the form you&#8217;ve implemented it originally.<br />
This is an <em>Extreme Programming</em> practice aptly named <a href="http://xp.c2.com/YouArentGonnaNeedIt.html">You Aren&#8217;t Gonna Need It</a>.</p>

<p>A classic example of <a href="http://xp.c2.com/YouArentGonnaNeedIt.html">YagNi</a> that I am paying dearly is a large application I&#8217;m working on at the moment (at least large from the perspective a single developer).<br />
It&#8217;s a fairly complex database application with an equally demanding winform GUI layer in C# on top.<br />
I built the GUI in a very modular fashion: each bit of information that could be grouped has its own <a href="http://msdn2.microsoft.com/en-us/library/system.windows.forms.usercontrol.aspx">User Control</a>, sealing its particularities.<br />
Then each of these controls is used in panels that embody another layer of functionality.<br />
Each panel is then loaded as needed into a form that display the panels on demand.<br />
The issue is that I now have to make major changes to the application and there are too many layers in these controls, making code hard to change.<br />
I had built it this way for re-use, thinking that it could be useful to have independent specialized controls, say for entering addresses, or customer details, etc.</p>

<p>Well, each of these controls took me a lot of time to craft, trying to make them as independent upon my particular implementation as I could. It turns out though that I&#8217;ve used each control no more than once -maybe twice for a couple- in the whole of the application, and I now realize that it&#8217;s unlikely that I would get another job that would require the exact same user-interface broken down the exact same way.<br />
So my uber-GUI controls are mostly a waste of time and complexity.</p>

<p>I should have simply created the forms directly, using <a href="http://www.devx.com/dotnet/Article/22603">partial classes</a> (a new .Net 2 feature) to separate each logical part into something manageable.<br />
My application would have been faster to develop and faster to run, with a lot less of unnecessary layers of abstraction.</p>

<p>I&#8217;m having a hard time with that, but I&#8217;m getting better, hopefully&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nkadesign.com/2006/you-arent-gonna-need-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

