<?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>Notes to self</title>
	<atom:link href="http://ntsblog.homedev.com.au/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://ntsblog.homedev.com.au</link>
	<description>my brain dump of solutions to technical problems</description>
	<lastBuildDate>Wed, 18 Apr 2012 13:45:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Windows Installer &#8211; Uninstall custom actions &#8211; WARNING!!!</title>
		<link>http://ntsblog.homedev.com.au/index.php/2012/04/18/windows-installer-uninstall-custom-actions-warning/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=windows-installer-uninstall-custom-actions-warning</link>
		<comments>http://ntsblog.homedev.com.au/index.php/2012/04/18/windows-installer-uninstall-custom-actions-warning/#comments</comments>
		<pubDate>Wed, 18 Apr 2012 13:45:31 +0000</pubDate>
		<dc:creator>jcrawfor74</dc:creator>
				<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://ntsblog.homedev.com.au/?p=740</guid>
		<description><![CDATA[With uninstall custom actions you have to be really careful. #1 Rule When working with uninstall custom actions, always encapsulate the custom action in a try / catch block! Why? If you are testing your uninstall process and it throws an exception you will be left with a half uninstalled application. As the application has [...]]]></description>
			<content:encoded><![CDATA[<p>With uninstall custom actions you have to be really careful.</p>
<h2>#1 Rule</h2>
<p>When working with uninstall custom actions, always encapsulate the custom action in a try / catch block!</p>
<p>Why?</p>
<p>If you are testing your uninstall process and it throws an exception you will be left with a half uninstalled application.<br />
As the application has not un-installed you cannot install a new version and as the uninstaller is compiled you cannot rebuild the installer to fix the error that is causing the exception.</p>
<p>How do I know this?</p>
<p>I did this exact thing. I was creating an installer that had custom actions for both install and uninstall.<br />
I caused an exception in the uninstall process and I was left with a product that could not be uninstalled!</p>
<h2>Can you recover from this?</h2>
<p>I found that in this scneario the Microsoft Fix-it tool is your saviour.</p>
<p>Download the fix it program from here, <a href="http://support.microsoft.com/mats/Program_Install_and_Uninstall" target="_new">Microsoft Fix-it Uninstaller</a></p>
<p>Run the program and follow the prompts. </p>
<p>I did a custom uninstall, chose my product that had failed to uninstall and it cleans up all the relevant registry keys so that it has been completely removed from the computer.</p>
<p>Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://ntsblog.homedev.com.au/index.php/2012/04/18/windows-installer-uninstall-custom-actions-warning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Background Worker Thread Code Sample with event handlers and cross thread invoke</title>
		<link>http://ntsblog.homedev.com.au/index.php/2012/03/30/background-worker-thread-code-sample-event-handlers-cross-thread-invoke/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=background-worker-thread-code-sample-event-handlers-cross-thread-invoke</link>
		<comments>http://ntsblog.homedev.com.au/index.php/2012/03/30/background-worker-thread-code-sample-event-handlers-cross-thread-invoke/#comments</comments>
		<pubDate>Thu, 29 Mar 2012 14:44:54 +0000</pubDate>
		<dc:creator>jcrawfor74</dc:creator>
				<category><![CDATA[c#]]></category>
		<category><![CDATA[Windows Forms]]></category>

		<guid isPermaLink="false">http://ntsblog.homedev.com.au/?p=708</guid>
		<description><![CDATA[The Problem So you want to create a windows form application. It needs to do the following: Do some work where its processing multiple items Have a progress bar that updates the progress of the application as it runs. Seems easy.. well here are the complexities: You want the main process to run on a [...]]]></description>
			<content:encoded><![CDATA[<h2>The Problem</h2>
<p>So you want to create a windows form application. It needs to do the following:</p>
<ol>
<li>Do some work where its processing multiple items
<li>Have a progress bar that updates the progress of the application as it runs.
</ol>
<p>Seems easy.. well here are the complexities:</p>
<ol>
<li>You want the main process to run on a background thread, so that the UI thread is available to update and render
<li>The background thread will need to raise events back to the main application to notify the application of the background thread progress.
<li>The progress bar will need to be updated to reflect the progress.
<li>The call to update the UI will crash because it is actually doing a cross-thread call, (the background thread, is trying to update the UI thread and this will crash.
</ol>
<p>This will walk you through the pattern for implementing this solution.</p>
<h2>Background Worker Thread</h2>
<p>This as the name suggests is a thread of execution that runs in the background in the application leaving the UI thread to do what it is good at, UI rendering. </p>
<p>If you were to try and have a method that processed 1000 records @ 2 seconds per record, and tried to update the progress bar on processing each record the UI would not render the progress bar as the UI thread is caught up in the process of doing the work.<br />
Doing the work on the background thread leave the UI thread to update the UI whilst the background thread gets on with doing the work.</p>
<p>What is the background thread and how do I create one?</p>
<p>First of all lets create a visual studio solution. I am going to create an empty windows form application called WorkerUtility. I will place the following controls on it. </p>
<ol>
<li>A button btnGo &#8211; labeled Go
<li>A progress bar; and
<li>A label called lblProgress &#8211; to show the % complete
</ol>
<p>The background worker thread can be found in the toolbox under the &#8220;Components&#8221; section.<br />
Drag the background worker thread onto you form and you will end up with a control called backGroundWorker1.</p>
<p>It should look like this:</p>
<p><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/03/WorkerUtilitySolution.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/03/WorkerUtilitySolution.png" alt="" title="WorkerUtilitySolution" width="600" height="353" class="aligncenter size-full wp-image-719" /></a></p>
<p>Set the following properties on the background worker control</p>
<ul>
<li><b>WorkerReportsProgress</b> true
</ul>
<p>Double click on the &#8220;Go&#8221; Button and setup the following Code<br />
<pre><code>
private void btnGo_Click(object sender, EventArgs e)
{
&nbsp;&nbsp;&nbsp;&nbsp;backgroundWorker1.RunWorkerAsync();
}
</code></pre></p>
<h2>Performing the Work and Raising Events</h2>
<p>I am going to simulate processing a 126 items @ Random number of seconds between 0 and 2 seconds, by looping and pausing the background thread. You could be doing anything in the processing block, for example, read data from the database loop through the rows and perform file system tasks based upon the data?</p>
<p>I will be performing work but each time an item is processed I want to tell the UI thread so that it can update the progress bar. To do this I will need to use events and I am going to create some custom event args.</p>
<p>Create a class called ProgressUpdatedEventArgs like the following:<br />
<pre><code>
using System;

namespace WorkerUtility
{
&nbsp;&nbsp;&nbsp;&nbsp;public class ProgressUpdatedEventArgs : EventArgs
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public ProgressUpdatedEventArgs(int total, int progress)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.Total = total;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.Processed = progress;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public int Processed { get; private set; }

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public int Total { get; private set; }
&nbsp;&nbsp;&nbsp;&nbsp;}
}
</code></pre></p>
<p>I will encapsulate the logic in a class called Processor.cs. Create a class as follows:<br />
This will house the event handler and raise events back to the UI thread</p>
<p>The main point of Interest in the following code is the creation of the event handler on the page with a delegate method declaration and an event handler. The RaiseEvent method is called on each file that is processed.</p>
<p><pre><code>
using System;

namespace WorkerUtility
{
&nbsp;&nbsp;&nbsp;&nbsp;public static class Processor
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public delegate void ProgressUpdatedEvent(ProgressUpdatedEventArgs progressUpdated);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public static event ProgressUpdatedEvent ProgressUpdated;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/// &lt;summary&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/// Main execution method that does the work
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/// &lt;/summary&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public static void Execute()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int total = 126 // this creates funny percentages
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Random randomGenerator = new Random();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (int i = 0; i &lt; total; i++)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Do some processing here

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;double delay = (double)randomGenerator.Next(2) + randomGenerator.NextDouble();

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int sleep = (int)delay * 1000;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.Threading.Thread.Sleep(sleep);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RaiseEvent(total, i + 1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private static void RaiseEvent(int total, int current)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (ProgressUpdated != null)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ProgressUpdatedEventArgs args = new ProgressUpdatedEventArgs(total, current);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ProgressUpdated(args);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
}
</code></pre></p>
<h2>Cross-Thread method invoke, handling the callback</h2>
<p>Now we need to set up an event handler in the main form so we can update the UI when the event is raised.</p>
<p>On the Background Worker Switch to the &#8220;Events&#8221; properties and double-click on &#8220;DoWork&#8221; to create the &#8220;DoWork&#8221; event handler.</p>
<p>Go to the _DoWork event handler and change as follows:</p>
<p><pre><code>
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
&nbsp;&nbsp;&nbsp;&nbsp;Processor.ProgressUpdated += new Processor.ProgressUpdatedEvent(Processor_ProgressUpdated);
&nbsp;&nbsp;&nbsp;&nbsp;Processor.Execute();
}

void Processor_ProgressUpdated(ProgressUpdatedEventArgs progressUpdated)
{

}
</code></pre></p>
<p>So this is where the tricky bit comes in. We need to implement the _ProgressUpdated callback.<br />
If we were to go directly to update the UI, we would get a cross thread exception and the program would crash.</p>
<div id="attachment_727" class="wp-caption aligncenter" style="width: 462px"><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/03/CrossThreadError.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/03/CrossThreadError.png" alt="" title="CrossThreadError" width="452" height="265" class="size-full wp-image-727" /></a><p class="wp-caption-text">Cross-thread operation not valid</p></div>
<p><pre><code>
Cross-thread operation not valid: Control &#039;progressBar1&#039; accessed from a 
thread other than the thread it was created on.
</code></pre></p>
<p>If you check the InvokeRequired method it will return true in this scenario so we need to perform a cross thread call to get from the background worker thread, that the &#8220;ProgressUpdated&#8221; event is raised on, to the UI thread to make the changes in the UI.</p>
<p>This is done as follows, firstly you need a delegate for the method invoke method callback and an Update Method to handle performing the UI Update.<br />
<pre><code>
public delegate void ProgressUpdatedCallaback(ProgressUpdatedEventArgs progress);

private void Processor_ProgressUpdated(ProgressUpdatedEventArgs progressUpdated)
{
&nbsp;&nbsp;if (InvokeRequired)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;Invoke(new ProgressUpdatedCallaback(this.UpdateProgress), new object[] { progressUpdated });
&nbsp;&nbsp;}
&nbsp;&nbsp;else
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;UpdateProgress(progressUpdated);
&nbsp;&nbsp;}
}

private void UpdateProgress(ProgressUpdatedEventArgs args)
{
&nbsp;&nbsp;if (progressBar1.Maximum != args.Total)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;// initial setup
&nbsp;&nbsp;&nbsp;&nbsp;progressBar1.Minimum = 0;
&nbsp;&nbsp;&nbsp;&nbsp;progressBar1.Maximum = args.Total;
&nbsp;&nbsp;&nbsp;&nbsp;progressBar1.Style = ProgressBarStyle.Continuous;
&nbsp;&nbsp;}

&nbsp;&nbsp;progressBar1.Value = args.Processed;

&nbsp;&nbsp;if (args.Total &gt; 0)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;double progress = args.Processed / (args.Total * 1.0);
&nbsp;&nbsp;&nbsp;&nbsp;lblProgress.Text = progress.ToString(&quot;P2&quot;);
&nbsp;&nbsp;}

&nbsp;&nbsp;Application.DoEvents();

}
</code></pre></p>
<p>Here is what it looks like running</p>
<p><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/03/WorkerUtility.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/03/WorkerUtility.png" alt="" title="WorkerUtility" width="520" height="125" class="aligncenter size-full wp-image-724" /></a></p>
<p>Here is the full working code sample in a VS2010 solution.<br />
<a href='http://ntsblog.homedev.com.au/wp-content/uploads/2012/03/WorkerUtility.zip'>WorkerUtility</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ntsblog.homedev.com.au/index.php/2012/03/30/background-worker-thread-code-sample-event-handlers-cross-thread-invoke/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell get &#8220;Return Value&#8221; from StoredProcedure ExecuteNonQuery</title>
		<link>http://ntsblog.homedev.com.au/index.php/2012/02/27/powershell-return-value-storedprocedure-executenonquery/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-return-value-storedprocedure-executenonquery</link>
		<comments>http://ntsblog.homedev.com.au/index.php/2012/02/27/powershell-return-value-storedprocedure-executenonquery/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 12:54:11 +0000</pubDate>
		<dc:creator>jcrawfor74</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://ntsblog.homedev.com.au/?p=681</guid>
		<description><![CDATA[The scenario is that from PowerShell you want to do the following: 1. Execute a stored Procedure 2. Check the Return Code from the stored procedure call. 3. Perform conditional logic based upon whether the stored procedure succeeded or failed The following will show you how to: 1. Create a PowerShell function to execute a [...]]]></description>
			<content:encoded><![CDATA[<p>The scenario is that from PowerShell you want to do the following:</p>
<p>1. Execute a stored Procedure<br />
2. Check the Return Code from the stored procedure call.<br />
3. Perform conditional logic based upon whether the stored procedure succeeded or failed</p>
<p>The following will show you how to:</p>
<ol>
<p>1. Create a PowerShell function to execute a stored procedure.<br />
2. Call this stored procedure and extract the return code into an integer variable<br />
3. Apply conditional logic based upon the return code</p>
<p>I struggled with getting this to work and did not find any exact examples that explained it exactly as I wanted.</p>
<h2>Environment Setup</h2>
<ol>
<li>SQL Server / Express &#8211; I am running SQL Sever 2008 R2 Express on the local host
<li>Create an empty Database called &#8220;TestDB&#8221;
<li>PowerShell configured with Remote-Signed Execution Policy. If you don&#8217;t know how to do this go here <a href="http://ntsblog.homedev.com.au/index.php/2012/02/27/set-powershell-executionpolicy/" target="_new">Set PowerShell Execution Policy</a>
</ol>
<h2>StoredProcedure</h2>
<p>Create a stored procedure as follows on your TestDB<br />
<pre><code>

IF&nbsp;&nbsp;EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N&#039;[dbo].[prcTest]&#039;) AND type in (N&#039;P&#039;, N&#039;PC&#039;))
DROP PROCEDURE [dbo].[prcTest]
GO

Create Procedure prcTest 
&nbsp;&nbsp;@value int
as
begin
&nbsp;&nbsp;Declare @return float
&nbsp;&nbsp;
&nbsp;&nbsp;BEGIN TRY
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;-- could return divide by 0 error if value = 0 
&nbsp;&nbsp;&nbsp;&nbsp;set @return = 1 / @value;
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;Return 0 -- success
&nbsp;&nbsp;
&nbsp;&nbsp;END TRY
&nbsp;&nbsp;BEGIN CATCH
&nbsp;&nbsp;&nbsp;&nbsp;-- will return 1 when there has been a divide by zero error
&nbsp;&nbsp;&nbsp;&nbsp;return 1
&nbsp;&nbsp;END CATCH
end

</code></pre></p>
<p>This procedure will accept a single integer parameter and divide by it. If zero is passed in the procedure will fail with a divide by zero error and return the return code of 1.<br />
Any other number will succeed.</p>
<p> 0 = Success and 1 = Error</p>
<h2>PowerShellScript</h2>
<p>Create a file called test.ps1 in your c:\Scripts directory.</p>
<p>You can run this from the PowerShell ISE or you can create a .bat file and past this line in it:<br />
<pre><code>
PowerShell.exe -noexit c:\scripts\test.ps1
</code></pre></p>
<p>The Power Shell Script is as follows:</p>
<p><pre><code>
function ConnectionString()
{
&nbsp;&nbsp;&nbsp;&nbsp;return &quot;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=TestDB;Data Source=.\SQLExpress&quot;;
}

function executeStoredProcedure($value)
{
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;$connection = ConnectionString;
&nbsp;&nbsp;&nbsp;&nbsp;$query = &quot;prcTest&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;$sqlConnection = new-object System.Data.SqlClient.SqlConnection $connection
&nbsp;&nbsp;&nbsp;&nbsp;$sqlConnection.Open() 
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;$sqlCmd = new-object System.Data.SqlClient.SqlCommand(&quot;$query&quot;, $sqlConnection) 

&nbsp;&nbsp;&nbsp;&nbsp;$sqlCmd.CommandType = [System.Data.CommandType]&quot;StoredProcedure&quot; 
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;$sqlCmd.Parameters.AddWithValue(&quot;@value&quot;, $value)

&nbsp;&nbsp;&nbsp;&nbsp;$sqlCmd.Parameters.Add(&quot;@ReturnValue&quot;, [System.Data.SqlDbType]&quot;Int&quot;) 
&nbsp;&nbsp;&nbsp;&nbsp;$sqlCmd.Parameters[&quot;@ReturnValue&quot;].Direction = [System.Data.ParameterDirection]&quot;ReturnValue&quot; 

&nbsp;&nbsp;&nbsp;&nbsp;$sqlCmd.ExecuteNonQuery() | out-null
&nbsp;&nbsp;&nbsp;&nbsp;$sqlConnection.Close() 

&nbsp;&nbsp;&nbsp;&nbsp;[int]$sqlCmd.Parameters[&quot;@ReturnValue&quot;].Value
&nbsp;&nbsp;&nbsp;&nbsp;
}

# Test 1 - Should fail
#======================================
Write-Host &quot;=====================&quot;
Write-Host &quot;TEST 1&quot;
Write-Host &quot;=====================&quot;
$out = executeStoredProcedure(0)
Write-Host $out
$returnValue = $out[2]
Write-Host $returnValue

if($returnValue -eq $null -or $returnValue -ne 0)
{
&nbsp;&nbsp;&nbsp;&nbsp;Write-Host &quot;An Error Occured&quot;
} 
else 
{
&nbsp;&nbsp;&nbsp;&nbsp;Write-Host &quot;Success&quot;
}

# Test 2 success
# ---------------
# removed the Write-Host lines 
#======================================
Write-Host &quot;=====================&quot;
Write-Host &quot;TEST 2&quot;
Write-Host &quot;=====================&quot;
$out = executeStoredProcedure(1)
$returnValue = $out[2]

if($returnValue -eq $null -or $returnValue -ne 0)
{
&nbsp;&nbsp;&nbsp;&nbsp;Write-Host &quot;An Error Occured&quot;
} 
else 
{
&nbsp;&nbsp;&nbsp;&nbsp;Write-Host &quot;Success&quot;
}
</code></pre></p>
<p>I will talk you through a few of the interesting points of above.</p>
<p>
<strong>ConnectionString Fuction</strong><br/><br />
I do this so I can have my connection string centralised in my script and that way if<br />
I need to change the SQL Server credentials I am using I only need to make the change in one place
</p>
<p>
<strong>[int]$sqlCmd.Parameters["@ReturnValue"].Value</strong><br/><br />
This gets the &#8220;ReturnValue&#8221; from the stored procedure and then casts it to an integer.</p>
<p>Note: I did try code like;<br />
<pre><code>
$rc = [int]$sqlCmd.Parameters[&quot;@ReturnValue&quot;].Value
return $rc
</code></pre><br />
But it made no difference to the output of the function.</p>
<p>
<strong>$returnValue = $out[2]</strong><br/><br />
I will confess I don&#8217;t now a great deal about PowerShell but I have worked through this problem to get a working solution.<br />
If you execute it and look at the output from the &#8220;Write-Host $out&#8221; you will see it appears to be an array type object and it prints as<br />
<pre><code>
@value @ReturnValue 1
</code></pre><br />
I figured this is a zero based array so I just accessed the value in position 3 i.e. $out[2], which is already of type &#8220;int&#8221; due to the cast in the function.
</p>
<p>
<strong>Conditional Logic</strong><br/><br />
So now I have the integer return value in a variable $returnValue I can use it in my conditional logic. If the value was null or <> 0 then it must be in error else success.</p>
<p>Implementing this means you can execute a stored procedure and if it fails , you can cancel any further processing in the Script. </p>
<p>Nice <img src='http://ntsblog.homedev.com.au/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://ntsblog.homedev.com.au/index.php/2012/02/27/powershell-return-value-storedprocedure-executenonquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Set PowerShell ExecutionPolicy</title>
		<link>http://ntsblog.homedev.com.au/index.php/2012/02/27/set-powershell-executionpolicy/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=set-powershell-executionpolicy</link>
		<comments>http://ntsblog.homedev.com.au/index.php/2012/02/27/set-powershell-executionpolicy/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 11:21:53 +0000</pubDate>
		<dc:creator>jcrawfor74</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://ntsblog.homedev.com.au/?p=671</guid>
		<description><![CDATA[When trying to run a PowerShell script you may get the following error: &#8220;scriptname.ps1 cannot be loaded because the execution of scripts is disabled on this system&#8221; You need to do the following to set the executionPolicy. 1. Run Powershell as Administrator 2. get-exeuctionPolicy 3. set-executionPolicy RemoteSigned 4. Enter Y 5. Check by running get-exeuctionPolicy [...]]]></description>
			<content:encoded><![CDATA[<p>When trying to run a PowerShell script you may get the following error:</p>
<p>&#8220;scriptname.ps1 cannot be loaded because the execution of scripts is disabled on this system&#8221;</p>
<p>You need to do the following to set the executionPolicy.</p>
<p>1. Run Powershell as Administrator<br />
2. get-exeuctionPolicy<br />
3. set-executionPolicy RemoteSigned<br />
4. Enter Y<br />
5. Check by running get-exeuctionPolicy<br />
&nbsp;</br><br />
&nbsp;</br><br />
<a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/PowerShellRemoteSigned.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/PowerShellRemoteSigned.png" alt="" title="PowerShellRemoteSigned" width="524" height="294" class="aligncenter size-full wp-image-673" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://ntsblog.homedev.com.au/index.php/2012/02/27/set-powershell-executionpolicy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enable Windows PowerShell ISE (Integrated Scripting Environment)</title>
		<link>http://ntsblog.homedev.com.au/index.php/2012/02/27/enable-windows-powershell-ise/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=enable-windows-powershell-ise</link>
		<comments>http://ntsblog.homedev.com.au/index.php/2012/02/27/enable-windows-powershell-ise/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 10:56:13 +0000</pubDate>
		<dc:creator>jcrawfor74</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://ntsblog.homedev.com.au/?p=662</guid>
		<description><![CDATA[On a Windows Server 2008 box you may be wondering where the Windows PowerShell ISE is. To Enable Bring up the Server Manager (Right-Click on &#8220;Computer&#8221;, choose manage Move to the Features Tab Choose &#8220;Add Features&#8221; Click &#8220;Windows PowerShell Integrated Scripting Environment&#8221; &#160; &#160; &#160; &#160; Click Next Click Install The IDE is now installed [...]]]></description>
			<content:encoded><![CDATA[<p>On a Windows Server 2008 box you may be wondering where the Windows PowerShell ISE is.</p>
<p>To Enable </p>
<ol>
<li>Bring up the Server Manager (Right-Click on &#8220;Computer&#8221;, choose manage
<li>Move to the Features Tab
<li>Choose &#8220;Add Features&#8221;
<li>Click &#8220;Windows PowerShell Integrated Scripting Environment&#8221;<br />
&nbsp;<br/><br />
&nbsp;<br/><br />
&nbsp;<br/></p>
<p>&nbsp;<br/><br />
  <a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/WindowsPowerShell.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/WindowsPowerShell.png" alt="" title="WindowsPowerShell" width="515" height="380" class="aligncenter size-full wp-image-663" /></a></p>
<li>Click Next
<li>Click Install
</ol>
<p>The IDE is now installed and can be found under:<br />
 &#8211; All Programs<br />
  &#8211; Accessories<br />
   &#8211; Windows PowerShell</p>
<p><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/WindowsPowerShellMenu.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/WindowsPowerShellMenu.png" alt="Windows Power Shell ISE Menu Location" title="WindowsPowerShellMenu" width="405" height="502" class="aligncenter size-full wp-image-664" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://ntsblog.homedev.com.au/index.php/2012/02/27/enable-windows-powershell-ise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASUS U3S6 Review &#8211; Benchmark SSD on Sata 3 add-on card against Sata II onboard</title>
		<link>http://ntsblog.homedev.com.au/index.php/2012/02/23/asus-u3s6-review-benchmark-sata-3-add-on-card-sata-ii-onboard/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=asus-u3s6-review-benchmark-sata-3-add-on-card-sata-ii-onboard</link>
		<comments>http://ntsblog.homedev.com.au/index.php/2012/02/23/asus-u3s6-review-benchmark-sata-3-add-on-card-sata-ii-onboard/#comments</comments>
		<pubDate>Thu, 23 Feb 2012 11:09:06 +0000</pubDate>
		<dc:creator>jcrawfor74</dc:creator>
				<category><![CDATA[Hardware Review]]></category>

		<guid isPermaLink="false">http://ntsblog.homedev.com.au/?p=581</guid>
		<description><![CDATA[Part 2 of my SSD SATA III performance tests. If you are here and haven&#8217;t seen part 1 &#8220;Sata 3 SSD running on onboard SATA II benchmark&#8221; go here >>> The Question Is there any reason to buy a SATA III expansion card to run your new SATA III SSD if your MOBO only has [...]]]></description>
			<content:encoded><![CDATA[<p>Part 2 of my SSD SATA III performance tests.</p>
<p>If you are here and haven&#8217;t seen part 1 &#8220;Sata 3 SSD running on onboard SATA II benchmark&#8221; <a href="http://ntsblog.homedev.com.au/index.php/2012/01/11/sata-3-ssd-running-on-sata-ii-benchmark/" title="SATA III running on onboard SATA II">go here >>> </a></p>
<h2>The Question</h2>
<p>Is there any reason to buy a SATA III expansion card to run your new SATA III SSD if your MOBO only has SATA II?</p>
<p>So I have a shiny new Corsair Force GT 120GB SATA III drive and an old SATA II motherboard.</p>
<p>Last article I benchmarked the performance to see what kind of experience you get when running on your onboard sata II connectors.</p>
<p>This article is the part 2 where I am going to benchmark the relative performance with a SATA III expansion card to see if there is any point is spending the money on one.</p>
<h2>The Test Card &#8211; ASUS U3S6</h2>
<p>&nbsp;<br />
<a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Marvell-88SE91231.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Marvell-88SE91231-150x150.png" alt="Marvell 88SE9123 Chipset" title="Marvell 88SE9123" width="150" height="150" class="alignright size-thumbnail wp-image-599" /></a></p>
<p>It was a bit hard to track one down in Australia so I had to buy this second-hand off the <a href="http://www.overclockers.com.au/"> overclockers australia forums</a>, but I wanted this card for its x4 PCI-e v2.0 connection.</p>
<p>Details of the U3S6 <a href="http://www.asus.com/Motherboards/Accessories/U3S6/" target="_blank">here</a>. </p>
<p>The U3 = USB 3.0 with a NEC chip set; and<br />
The S6 = Sata III 6.0Gb/s Marvel 88SE9123 controller.</p>
<p>&nbsp;
<p><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/ASUS_U3S6_1.jpg"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/ASUS_U3S6_1-1024x768.jpg" alt="ASUS U3S6 Sata III PCIe expansion card" title="ASUS_U3S6_1" width="600" height="450" class="aligncenter size-large wp-image-596" /></a></p>
<p><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/ASUS_U3S6_2.jpg"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/ASUS_U3S6_2-300x224.jpg" alt="ASUS U3S6 Sata III PCIe expansion card" title="ASUS_U3S6_2" width="300" height="224" class="alignleft size-medium wp-image-597" /></a><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Firmware-Version.jpg"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Firmware-Version-300x224.jpg" alt="ASUS U3S6 Default Firmware Boot Screen Shot" title="Firmware Version" width="300" height="224" class="alignright size-medium wp-image-598" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The card has yet to be flashed from its original bios which appears as 1.0.0.1012.</p>
<p>I decided to play it safe and rather than flash the bios and destroy the card I would start from scratch, benchmark it first. Later I will play and see if I can improve on stock performance results, buy flashing to later versions of the firmware.</p>
<p>At on OS software level I tested with 2 driver configurations:</p>
<table width="100%" border="0">
<tr>
<td align="center">1.0.0.1036</td>
<td>and</td>
<td>1.2.0.1016</td>
</tr>
<tr>
<td><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Marvell-Driver_1036.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Marvell-Driver_1036-278x300.png" alt="Marvell Driver 1.0.0.1036 Screenshot" title="Marvell Driver_1036" width="278" height="300" class="alignleft size-medium wp-image-586" /></a></td>
<td>&nbsp;</td>
<td>
<a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Marvell-Driver_1.2.0.1016.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Marvell-Driver_1.2.0.1016-278x300.png" alt="" title="Marvell Driver_1.2.0.1016 - Marvell Driver" width="278" height="300" class="alignright size-medium wp-image-587" /></a>
</td>
</table>
<p>with some interesting results..</p>
<p>The latest drivers are best found on <a href="http://www.station-drivers.com/page/marvell.htm">station-drivers</a>. It&#8217;s french but version numbers can be read easily, go to the bottom for the MV91xx drivers and firmware.</p>
<h2>The test rig</h2>
<table width="100%">
<tr>
<td><strong>Mother&nbsp;Board:</strong></td>
<td> Socket 775, Gigabyte EP45-DS3</td>
</tr>
<tr>
<td><strong>CPU:</strong></td>
<td>Core 2 Duo E8400 3.0Ghz, running overclocked @ 4.0Ghz.</td>
</tr>
<tr>
<td><strong>Memory:</strong></td>
<td>4GB (2x2GB) Corsair CM2X2048-8500C5C (1066Mhz)</td>
</tr>
<tr>
<td><strong>Video:</strong></td>
<td>MSi R6850 Storm II 1G OC (R6850 PM2DIGD5)</td>
</tr>
<tr>
<td><strong>SSD:</strong></td>
<td>Corsair Force GT 120GB, (1.3.3 firmware on SATA II in AHCI mode)</td>
</tr>
<tr>
<td><strong>SATA III Card</strong></td>
<td>Asus U3S6 (firware 1012)</td>
</tr>
<tr>
<td><strong>OS:</strong></td>
<td>Windows 7 SP1 &#8211; 64 bit</td>
</tr>
</tr>
</table>
<p>The U3S6 is a x4 card and will run on PCI-E v2.0. The EP45-DS3 only has 3 x PCI-e 1.0 x1 ports, and has a x16 and x8 PCI-e v2.0 slot.</p>
<p>The x16 slot is currently running my MSi HD 6850, and the x8 slot is free.</p>
<p>The U3S6 is therefore running in the x8 slot.</p>
<p>I was interested in seeing what might happen when running something like crysis whilst having the U3S6 trying to use the same bus.</p>
<h2>Synthetic Benchmarks</h2>
<h3>AS SSD</h3>
<p>My original SATA II Benchmark score on SATA II was 480! I did this benchmark on day 1 of a clean Windows 7 install. Since then I have been using the computer for a few months and the drive is about 50% full so I benchmarked with AS SSD again.</p>
<p>I did numerous benchmarks with in multiple different driver and SATA configurations. The Read speed seemed to give consistent results across similar benchmarks but the write performance (particularly the 4K-64-Thrd) was a bit all over the place and seemed to influence heavily the overall score giving results between 395 and 450.</p>
<p>The following results are the best of each run:</p>
<p><strong>SATA II &#8211; Rerun</strong><br/><br />
<a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/as-ssd-bench-Corsair-Force-GT-23.02.2012-10-23-09-PM-SATA-II.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/as-ssd-bench-Corsair-Force-GT-23.02.2012-10-23-09-PM-SATA-II-300x298.png" alt="SATA II Benchmark" title="as-ssd-bench Corsair Force GT 23.02.2012 10-23-09 PM SATA II" width="300" height="298" class="aligncenter size-medium wp-image-630" /></a><br />
<br/></p>
<p><strong>U3S6 &#8211; 1.0.0.1036</strong><br />
<a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/ASSD_U3S6_drv1036.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/ASSD_U3S6_drv1036-300x298.png" alt="ASUS U3S6 1036 Driver AS SSD benchmark" title="ASSD_U3S6_drv1036" width="300" height="298" class="aligncenter size-medium wp-image-629" /></a></p>
<p><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/AASD_Compression_U3S6_drv1036.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/AASD_Compression_U3S6_drv1036-300x191.png" alt="ASUS U3S6 1.0.0.1036 Driver Compression Benchmark" title="AASD_Compression_U3S6_drv1036" width="300" height="191" class="aligncenter size-medium wp-image-635" /></a></p>
<p><strong>U3S6 &#8211; 1.2.0.1016</strong><br />
<br/><br />
<a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/as-ssd-bench_drv1.2.0.1016.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/as-ssd-bench_drv1.2.0.1016-300x298.png" alt="U3S6 on 1.2.0.1016 driver AS SSD benchmark" title="as-ssd-bench_drv1.2.0.1016" width="300" height="298" class="aligncenter size-medium wp-image-631" /></a></p>
<p>The U3S6 seems to have better sequential read of approx 340MB/s. This is only a 75MB/s improvement.</p>
<p>I noted that generally the benchmark results for the earlier 1.0.0.1036 driver were slightly better and more consistent than the later 1.2.0.1016 driver.</p>
<p>Also the Read performance was generally consistent but the 4k and 4k-64Thrd write times were up and down.</p>
<h3>Crystal Disk mark</h3>
<p>Given the fluctuations I also tried Crystal Disk mark which seemed to give similar results without the randomness.</p>
<p><strong>SATA II &#8211; Rerun</strong><br/><br />
<a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/CDM3_SATAII.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/CDM3_SATAII.png" alt="Crysal Disk Corsair Force GT 120GB SSD Benchmark on SATA II" title="CDM3_SATAII" width="416" height="378" class="aligncenter size-full wp-image-638" /></a></p>
<p><strong>U3S6 &#8211; 1.0.0.1036</strong><br />
<a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/CDM3_1036.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/CDM3_1036.png" alt="Crystal Disk Corsair Force GT ASUS U3S6 Benchmark Driver 1.0.0.1036" title="CDM3_1036" width="416" height="378" class="aligncenter size-full wp-image-637" /></a></p>
<p><strong>U3S6 &#8211; 1.2.0.1016</strong><br />
<a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/CDM3_1016.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/CDM3_1016.png" alt="Crystal Disk Corsair Force GT ASUS U3S6 Benchmark Driver 1.2.0.1016" title="CDM3_1016" width="416" height="378" class="aligncenter size-full wp-image-636" /></a></p>
<p>Again the 1.0.0.1036 driver seemed to out perform its older brother.</p>
<h2>Windows Start Up Times</h2>
<h3>The test</h3>
<p>Same as last time, the benchmark recorded the time from when windows started loading after the POST screen, until a working desktop was available. This was identified as the time at which the Gadgets appeared on the desktop. This was split into 3 timing points</p>
<ol>
<li>time to login screen
<li>time to login
<li>time to see the desktop and the gadgets loaded.
</ol>
<p><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Windows-Startup.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Windows-Startup.png" alt="Windows 7 Startup times Benchmark SSD results" title="Windows Startup" width="481" height="289" class="aligncenter size-full wp-image-642" /></a><br />
The fastest startup time was still SATA II and the 1.2.0.1016 driver made a difference but the 1.0.1036 was consistently a few seconds slower to boot.</p>
<h2>Windows Experience</h2>
<p>The only score to change when running the U3S6 was the Disk from 7.8 to 7.9. Note: 7.9 is currently the maximum rating.<br />
<a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Windows-Experience-Score.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Windows-Experience-Score.png" alt="Windows Experience Score on the SSD SATA III" title="Windows Experience Score" width="543" height="203" class="aligncenter size-full wp-image-641" /></a></p>
<h2>Crysis Benchmarks</h2>
<p>I didn&#8217;t bother with the load time tests as I figured they would be comparable. </p>
<p>I did however run the Benchmarks for both Crysis and Crysis 2 in the various configurations, with some interesting results.</p>
<h3>Crysis Benchmark</h3>
<p>The crysis benchmark was run @ 1920&#215;1080 &#8211; 64-bit and DirectX 10<br />
The benchmark was run with the following SSD connections</p>
<ol>
<li>SATA II
<li>U3S6 1.0.0.1036
</ol>
<p><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Crysis.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Crysis.png" alt="Crysis Benchmark " title="Crysis" width="481" height="289" class="aligncenter size-full wp-image-644" /></a></p>
<p>The results were almost identical. No change here.</p>
<h3>Crysis 2 Benchmark</h2>
<p>The benchmark was run on DirectX 11 on the Times Square Map.</p>
<p><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Crysis2.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Crysis2.png" alt="Crysis 2 Benchmark" title="Crysis2" width="481" height="289" class="aligncenter size-full wp-image-648" /></a></p>
<p>The most interesting thing here is that when the video card was being pushed by crysis 2, the PCIe channel appears to be compromised by the SSD drive running on the x8 port.</p>
<p>This can be seen in the poor fps on the two higher settings.</p>
<h2>USB Performance</h2>
<p>Just to see how the USB 3.0 worked I hooked up my Western Digital 1 TB external hard drive and did a 4.14GB and 15.5 GB file copy both up to and down from the External drive.</p>
<p>I found the 15.5GB copy onto the external drive took 10m 1s @ USB 2.0 but only took 3m 52s on USB 3.0. The copy down from the external driver took 9m 11s @ USB 2.0 and 3m 43s @ USB 3.0.<br />
The copy rates were approx 27.1 MB/s combined for USB 2.0 whilst USB 3.0 achieved 67.9 Mb/s or 2.5 times faster. Nice.</p>
<h2>Why so slow?</h2>
<p>I have gotten around to flashing the Card. At first it felt like &#8220;flushing&#8221; not &#8220;flashing&#8221; as the firmwares I tried off &#8220;Station-Drivers&#8221; broke the card. After a few hours of flashing I finally got the driver working with Firmware revision 1028 &#8220;Firmware pour U3S6 Rev 0 (MV-9123) Version:1.0.0.1028) Mod by Daoud333&#8243;</p>
<p>So when I start it up I see the following</p>
<p><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Bios-1028.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Bios-1028.png" alt="ASUS U3S6 firmware 1028 Screenshot on startup" title="Bios 1028" width="500" height="150" class="aligncenter size-full wp-image-650" /></a></p>
<p>PCIe x1 5.0Gbps. x1 why x1, its a x4 card running in a x8 slot?</p>
<p>After some digging I found this spec document on the controller, <a href="http://www.marvell.com/storage/system-solutions/assets/Marvell-88SE91XX-Host-Controllers.pdf" target="_blank" title="Product Brief">Marvell 88SE91xx Product Brief</a>. If you read this the spec fo the controller shows this..</p>
<p><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Marvell-Controller.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/02/Marvell-Controller.png" alt="Marvell 88SE 9123 x1 PCIe" title="Marvell Controller" width="410" height="211" class="aligncenter size-full wp-image-651" /></a></p>
<p>The controller only supports a single x1 connection.</p>
<p>I feel a bit duped. I specifically got this card for its x4 connection, but given the fact the marvel controller only accepts a x1 connection the SATA will only ever be able to run at this speed. I have read other people suggest that the x4 is used to split the channel in half and use some of the x 4 bandwidth for the USB 3.0 controller, which would make sense but it seems like false advertising to me.</p>
<h2>Conclusion</h2>
<p>Overall I think if you are out of SATA ports on your PC and need a few more,  then the card is OK as long as you are NOT using it for gaming.<br />
The sequential read is slightly better but this is only a benchmark figure as it did not translate in the real world.<br />
The only other nicety is the USB 3.0 which will come in handy in the future.</p>
<p>I think in the next few months The <a href="http://www.marvell.com/storage/system-solutions/assets/Marvell-88SE92xx-Product-Brief.pdf" target="_blank">Marvel 92xx controllers </a><br />
will start to appear and these may allow my SSD to run to its full potential as this supports PCIe x2.</p>
<p>Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://ntsblog.homedev.com.au/index.php/2012/02/23/asus-u3s6-review-benchmark-sata-3-add-on-card-sata-ii-onboard/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Router Logging Software &#8211; Free &#8211; MyRouter Log</title>
		<link>http://ntsblog.homedev.com.au/index.php/2012/01/31/router-logging-software-free-myrouter-log/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=router-logging-software-free-myrouter-log</link>
		<comments>http://ntsblog.homedev.com.au/index.php/2012/01/31/router-logging-software-free-myrouter-log/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 09:07:40 +0000</pubDate>
		<dc:creator>jcrawfor74</dc:creator>
				<category><![CDATA[Free Software]]></category>

		<guid isPermaLink="false">http://ntsblog.homedev.com.au/?p=576</guid>
		<description><![CDATA[My router was crashing a bit and I thought I would check the router logs to see if there was any clues in there as to what was going on? Once my router crashes the log files are lost, so I went in search of some router logging software. In short I tried a few [...]]]></description>
			<content:encoded><![CDATA[<p>My router was crashing a bit and I thought I would check the router logs to see if there was any clues in there as to what was going on?</p>
<p>Once my router crashes the log files are lost, so I went in search of some router logging software. </p>
<p>In short I tried a few and they were buggy pieces of rubbish that didn&#8217;t work.</p>
<p>It&#8217;s just a simple UDP listening program, and so In the immortal words of Jeremy Clarkson (Top Gear, UK), &#8220;How hard could it be?&#8221;, so I wrote my own.</p>
<p>Its called &#8220;MyRouter Log&#8221; and it&#8217;s a UDP port listener for capturing to a text log file, the contents of your routers UDP broadcast.</p>
<p>Its free and full details can be found here on my site, <a href="http://www.homedev.com.au/Free/View/3" target="_blank">MyRouter Log</a></p>
<p>Hope you like it and give me some feedback in case my software is a &#8220;buggy piece of rubbish&#8221; <img src='http://ntsblog.homedev.com.au/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> &#8221;</p>
<p><img alt="" src="http://www.homedev.com.au/Content/images/screenshots/3/b3fad2b9-c3d0-48fe-9b93-25a4efd77b1f.png" title="MyRouter Log" class="aligncenter" width="588" height="405" /></p>
]]></content:encoded>
			<wfw:commentRss>http://ntsblog.homedev.com.au/index.php/2012/01/31/router-logging-software-free-myrouter-log/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JetPack Post Statistics Link Plug-in</title>
		<link>http://ntsblog.homedev.com.au/index.php/2012/01/25/jetpack-post-statistics-link-plug-in/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jetpack-post-statistics-link-plug-in</link>
		<comments>http://ntsblog.homedev.com.au/index.php/2012/01/25/jetpack-post-statistics-link-plug-in/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 14:23:23 +0000</pubDate>
		<dc:creator>jcrawfor74</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://ntsblog.homedev.com.au/?p=562</guid>
		<description><![CDATA[You may have noticed that the jetpack plugin provides you with some great statistics on the hits to your website. It also allows you to drill down on the statistics for each post, with one problem&#8230; If your post does not appear in the top 10 results for the day then you have no way [...]]]></description>
			<content:encoded><![CDATA[<p>You may have noticed that the jetpack plugin provides you with some great statistics on the hits to your website. </p>
<p>It also allows you to drill down on the statistics for each post, with one problem&#8230;</p>
<p>If your post does not appear in the top 10 results for the day then you have no way to see the statistics.</p>
<p>That is where the &#8220;JetPack Post Statistics Link Plug-in&#8221; comes in.</p>
<p>The plug-in provides an extra column on your Posts admin page and provides a link to the statistics for each post.</p>
<p>To download a copy go to my main website.. <a href="http://www.homedev.com.au/WordPress/View/2" title="HomeDev WordPress Plugin" target="_new"> >> Download Link << </a></p>
<p><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/01/screenshot-1.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/01/screenshot-1.png" alt="" title="screenshot-1" width="681" height="285" class="aligncenter size-full wp-image-564" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://ntsblog.homedev.com.au/index.php/2012/01/25/jetpack-post-statistics-link-plug-in/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crysis 2 50Hz issue ATI Card on HDMI connection</title>
		<link>http://ntsblog.homedev.com.au/index.php/2012/01/16/crysis-2-50hz-issue-ati-card-hdmi-connection/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=crysis-2-50hz-issue-ati-card-hdmi-connection</link>
		<comments>http://ntsblog.homedev.com.au/index.php/2012/01/16/crysis-2-50hz-issue-ati-card-hdmi-connection/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 12:24:59 +0000</pubDate>
		<dc:creator>jcrawfor74</dc:creator>
				<category><![CDATA[Hardware Issues]]></category>

		<guid isPermaLink="false">http://ntsblog.homedev.com.au/?p=543</guid>
		<description><![CDATA[I have been running Crysis 2 on my DVI connection no worries, but recently I changed to a HDMI cable to connect my Benq E2420HD to my Msi R6850 video card. If you see my previous post, Benq Monitor and HDMI not working you will see that I had some issues with getting my monitor [...]]]></description>
			<content:encoded><![CDATA[<p>I have been running Crysis 2 on my DVI connection no worries, but recently I changed to a HDMI cable to connect my Benq E2420HD to my Msi R6850 video card.</p>
<p>If you see my previous post, <a href="http://ntsblog.homedev.com.au/index.php/2012/01/14/benq-monitor-hdmi-working-fixed/" target="_blank">Benq Monitor and HDMI not working</a> you will see that I had some issues with getting my monitor to work, but I found the settings and all was good with the world.. until I launched Crysis 2.</p>
<h2>Issue</h2>
<p>When Crysis 2 runs with DX 11 in full screen mode, it runs @ 50Hz.</p>
<p><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/01/OSD_Crysis.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/01/OSD_Crysis.png" alt="" title="OSD_Crysis" width="420" height="313" class="aligncenter size-full wp-image-546" /></a></p>
<p>My monitor can handle 50Hz, (it is a supported refresh rate), but the game did not fill the full screen. The full screen was black but the edges of the game fell about 1cm short or the edge of my screen.</p>
<p><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/01/Crysis_screen1.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/01/Crysis_screen1.png" alt="" title="Crysis_screen1" width="480" height="360" class="aligncenter size-full wp-image-544" /></a></p>
<p><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/01/Crysis_screen2.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/01/Crysis_screen2.png" alt="" title="Crysis_screen2" width="480" height="360" class="aligncenter size-full wp-image-545" /></a></p>
<p>So WTF was going on?</p>
<h2>Catalyst Control Centre.. again..</h2>
<p>The issue is the overscan setting. As per the previous post (link above), I had to set the overscan setting to 0%. But when the monitor switches to 50Hz it also switches to a different profile, and this profile has the overscan setting to about the middle of this bar, (approx 7.5% underscan)</p>
<p><a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/01/Catalyst.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/01/Catalyst.png" alt="" title="Catalyst" width="486" height="528" class="aligncenter size-full wp-image-526" /></a></p>
<p>The solution is:</p>
<ol>
<li>Launch Catalyst control centre
<li>Expand &#8220;Desktop Management&#8221; and click on &#8220;Desktop Properties&#8221;
<li>Set the monitor to use 50Hz and click apply<br/> <i>your monitor will switch and wow you suddenly see the black border similar to when you were playing Crysis 2</i>
<li>Switch to the &#8220;Scaling Options&#8221; and set the Overscan to 0% and click apply
</ol>
<p>When you play Crysis it will now fill the full screen.</p>
<p>Got to go.. stuff to shoot .. <img src='http://ntsblog.homedev.com.au/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://ntsblog.homedev.com.au/index.php/2012/01/16/crysis-2-50hz-issue-ati-card-hdmi-connection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Benq Monitor and HDMI not working &#8211; FIXED</title>
		<link>http://ntsblog.homedev.com.au/index.php/2012/01/14/benq-monitor-hdmi-working-fixed/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=benq-monitor-hdmi-working-fixed</link>
		<comments>http://ntsblog.homedev.com.au/index.php/2012/01/14/benq-monitor-hdmi-working-fixed/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 08:16:09 +0000</pubDate>
		<dc:creator>jcrawfor74</dc:creator>
				<category><![CDATA[Hardware Issues]]></category>

		<guid isPermaLink="false">http://ntsblog.homedev.com.au/?p=525</guid>
		<description><![CDATA[Attaching a monitor to a pc via HDMI should be easy&#8230; right. Well on hooking up a Benq E2420HD monitor to a MSi R6850 (PM2DIGD5), the image looked terrible. It took a bit of tweaking but these are the steps you will need to follow to get things looking how they should. Step 1. Catalyst [...]]]></description>
			<content:encoded><![CDATA[<p>Attaching a monitor to a pc via HDMI should be easy&#8230; right.</p>
<p>Well on hooking up a Benq E2420HD monitor to a MSi R6850 (PM2DIGD5), the image looked terrible.</p>
<p>It took a bit of tweaking but these are the steps you will need to follow to get things looking how they should.</p>
<p><br/></p>
<p><br/></p>
<h2>Step 1. Catalyst Control Centre Settings</h2>
<p>In my case the software was defaulting to set the scaling options to &#8220;under scaled&#8221;! (about -7.5%)</p>
<p>Turn the scaling off and set it to 0% as shown.<br/><br />
<a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/01/Catalyst.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/01/Catalyst.png" alt="" title="Catalyst" width="486" height="528" class="aligncenter size-full wp-image-526" /></a></p>
<h2>Step 2. Monitor Settings</h2>
<p>You need to turn off the overscan feature, in the monitors OSD (on-screen display) settings.</p>
<ol>
<li>Go to the Picture Advanced page and choose display mode</br><br />
<a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/01/OSD_1.jpg"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/01/OSD_1.jpg" alt="On Screen Display 1" title="OSD_1" width="385" height="296" class="aligncenter size-full wp-image-527" /></a></p>
<li>Set the Overscan feature to OFF<br/><br />
<a href="http://ntsblog.homedev.com.au/wp-content/uploads/2012/01/OSD_2.png"><img src="http://ntsblog.homedev.com.au/wp-content/uploads/2012/01/OSD_2.png" alt="On screen display overscan" title="OSD_2" width="407" height="264" class="aligncenter size-full wp-image-528" /></a></p>
<p>Problem solved <img src='http://ntsblog.homedev.com.au/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />
</ol>
]]></content:encoded>
			<wfw:commentRss>http://ntsblog.homedev.com.au/index.php/2012/01/14/benq-monitor-hdmi-working-fixed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

