<?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>Tallan&#039;s Technology Blog</title>
	<atom:link href="http://blog.tallan.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tallan.com</link>
	<description>Tallan&#039;s Top Technologists Share Their Thoughts on Today&#039;s Technology Challenges</description>
	<lastBuildDate>Fri, 03 Feb 2012 17:23:33 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Automatically log errors with Elmah in Script0Service-WebService calls</title>
		<link>http://blog.tallan.com/2012/02/03/automatically-log-errors-with-elmah-in-script0service-webservice-calls/</link>
		<comments>http://blog.tallan.com/2012/02/03/automatically-log-errors-with-elmah-in-script0service-webservice-calls/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 17:23:33 +0000</pubDate>
		<dc:creator>Karl Schwirz</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[.net]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/2012/02/03/automatically-log-errors-with-elmah-in-script0service-webservice-calls/</guid>
		<description><![CDATA[If you’ve used Elmah logging in the past then you know it’s a very useful and easy to set up tool in your web applications.&#160; However, when we encounter errors in web services we sometimes do not get the desired logging into the xml file or database, depending on how you have Elmah configured.&#160; This [...]]]></description>
			<content:encoded><![CDATA[<p>If you’ve used Elmah logging in the past then you know it’s a very useful and easy to set up tool in your web applications.&#160; However, when we encounter errors in web services we sometimes do not get the desired logging into the xml file or database, depending on how you have Elmah configured.&#160; This is because when a error occurs in a script service enabled web service, the errors get serialized into JSON and returned to the ajax caller which is then take by the javascript to handle the exception.&#160; The application is left unaware of the exception occurrence. </p>
<p>There is a way however, to intercept the message before it is returned to the front-end and log the error automatically the way we are used to with Elmah.</p>
<p>First we set up an ErrorHandlerFilter class which will override the default error stream message ( {“Message”:”There was an error processing the request.”, “StackTrace”:””, “ExceptionType”:””})} with a more meaningful error message with details.</p>
<div>
<div>
<pre><span style="color: #606060">   1:</span> <span style="color: #0000ff">using</span> System;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   2:</span> <span style="color: #0000ff">using</span> System.Collections.Generic;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   3:</span> <span style="color: #0000ff">using</span> System.IO;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   4:</span> <span style="color: #0000ff">using</span> System.Linq;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   5:</span> <span style="color: #0000ff">using</span> System.Text;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   6:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   7:</span> <span style="color: #0000ff">namespace</span> Namespace.ElmahExtension</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   8:</span> {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   9:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> ErrorHandlerFilter : Stream</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  10:</span>     {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  11:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  12:</span>         <span style="color: #0000ff">private</span> <span style="color: #0000ff">readonly</span> Stream _responseFilter;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  13:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  14:</span>         <span style="color: #0000ff">public</span> List&lt;<span style="color: #0000ff">byte</span>&gt; OriginalBytesWritten { get; <span style="color: #0000ff">private</span> set; }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  15:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  16:</span>         <span style="color: #0000ff">private</span> <span style="color: #0000ff">const</span> <span style="color: #0000ff">string</span> Content =</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  17:</span>           <span style="color: #006080">&quot;{\&quot;Message\&quot;:\&quot;There was an error processing the request.\&quot;&quot;</span> +</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  18:</span>           <span style="color: #006080">&quot;,\&quot;StackTrace\&quot;:\&quot;\&quot;,\&quot;ExceptionType\&quot;:\&quot;\&quot;}&quot;</span>;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  19:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  20:</span>         <span style="color: #0000ff">public</span> ErrorHandlerFilter(Stream responseFilter)</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  21:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  22:</span>             _responseFilter = responseFilter;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  23:</span>             OriginalBytesWritten = <span style="color: #0000ff">new</span> List&lt;<span style="color: #0000ff">byte</span>&gt;();</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  24:</span>         }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  25:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  26:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">void</span> Flush()</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  27:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  28:</span>             <span style="color: #0000ff">byte</span>[] bytes = Encoding.UTF8.GetBytes(Content);</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  29:</span>             _responseFilter.Write(bytes, 0, bytes.Length);</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  30:</span>             _responseFilter.Flush();</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  31:</span>         }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  32:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  33:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">long</span> Seek(<span style="color: #0000ff">long</span> offset, SeekOrigin origin)</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  34:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  35:</span>             <span style="color: #0000ff">return</span> _responseFilter.Seek(offset, origin);</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  36:</span>         }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  37:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  38:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">void</span> SetLength(<span style="color: #0000ff">long</span> <span style="color: #0000ff">value</span>)</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  39:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  40:</span>             _responseFilter.SetLength(<span style="color: #0000ff">value</span>);</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  41:</span>         }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  42:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  43:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">int</span> Read(<span style="color: #0000ff">byte</span>[] buffer, <span style="color: #0000ff">int</span> offset, <span style="color: #0000ff">int</span> count)</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  44:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  45:</span>             <span style="color: #0000ff">return</span> _responseFilter.Read(buffer, offset, count);</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  46:</span>         }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  47:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  48:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">void</span> Write(<span style="color: #0000ff">byte</span>[] buffer, <span style="color: #0000ff">int</span> offset, <span style="color: #0000ff">int</span> count)</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  49:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  50:</span>             <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i = offset; i &lt; offset + count; i++)</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  51:</span>             {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  52:</span>                 OriginalBytesWritten.Add(buffer[i]);</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  53:</span>             }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  54:</span>         }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  55:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  56:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">bool</span> CanRead</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  57:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  58:</span>             get { <span style="color: #0000ff">return</span> _responseFilter.CanRead; }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  59:</span>         }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  60:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  61:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">bool</span> CanSeek</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  62:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  63:</span>             get { <span style="color: #0000ff">return</span> _responseFilter.CanSeek; }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  64:</span>         }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  65:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  66:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">bool</span> CanWrite</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  67:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  68:</span>             get { <span style="color: #0000ff">return</span> _responseFilter.CanWrite; }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  69:</span>         }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  70:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  71:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">long</span> Length</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  72:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  73:</span>             get { <span style="color: #0000ff">return</span> _responseFilter.Length; }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  74:</span>         }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  75:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  76:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">long</span> Position</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  77:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  78:</span>             get { <span style="color: #0000ff">return</span> _responseFilter.Position; }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  79:</span>             set { _responseFilter.Position = <span style="color: #0000ff">value</span>; }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  80:</span>         }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  81:</span>     }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  82:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>Now, we’re going to need to set up a class that implements I<em>HttpModule.&#160; </em>which we’ll use to intercept the message being passed after the <em>Request </em>and <em>EndRequest</em> handlers execute.</p>
<div>
<div>
<pre><span style="color: #606060">   1:</span> <span style="color: #0000ff">using</span> System;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   2:</span> <span style="color: #0000ff">using</span> System.Diagnostics;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   3:</span> <span style="color: #0000ff">using</span> System.IO;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   4:</span> <span style="color: #0000ff">using</span> System.Text;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   5:</span> <span style="color: #0000ff">using</span> System.Web;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   6:</span> <span style="color: #0000ff">using</span> System.Web.Services.Protocols;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   7:</span> <span style="color: #0000ff">using</span> Elmah;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   8:</span>  </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   9:</span> <span style="color: #0000ff">namespace</span> Namespace.ElmahExtension</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  10:</span> {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  11:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> ElmahExtension : IHttpModule</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  12:</span>     {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  13:</span>         <span style="color: #0000ff">private</span> HttpApplication _application;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  14:</span>  </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  15:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> Dispose()</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  16:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  17:</span>         }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  18:</span>  </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  19:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> Init(HttpApplication context)</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  20:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  21:</span>             _application = context;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  22:</span>             _application.PostRequestHandlerExecute += OnPostRequestHandlerExecute;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  23:</span>             _application.EndRequest += OnEndRequest;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  24:</span>         }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  25:</span>  </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  26:</span>         <span style="color: #0000ff">private</span> <span style="color: #0000ff">void</span> OnPostRequestHandlerExecute(<span style="color: #0000ff">object</span> sender, EventArgs e)</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  27:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  28:</span>             var context = sender <span style="color: #0000ff">as</span> HttpApplication;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  29:</span>             <span style="color: #0000ff">if</span>(context != <span style="color: #0000ff">null</span> &amp;&amp; (context.Request.Path.Contains(<span style="color: #006080">&quot;.asmx&quot;</span>) &amp;&amp; (context.Response.StatusCode &gt;= 400 &amp;&amp; context.Response.StatusCode &lt; 600)))</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  30:</span>             {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  31:</span>                 context.Response.Filter = <span style="color: #0000ff">new</span> ErrorHandlerFilter(context.Response.Filter);</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  32:</span>             }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  33:</span>         }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  34:</span>  </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  35:</span>         <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> OnEndRequest(<span style="color: #0000ff">object</span> sender, EventArgs e) </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  36:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  37:</span>             var context = (HttpApplication)sender;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  38:</span>             var errorHandlerFilter = context.Response.Filter <span style="color: #0000ff">as</span> ErrorHandlerFilter;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  39:</span>  </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  40:</span>             <span style="color: #0000ff">if</span> (errorHandlerFilter == <span style="color: #0000ff">null</span>)</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  41:</span>             {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  42:</span>                 <span style="color: #0000ff">return</span>;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  43:</span>             }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  44:</span>  </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  45:</span>             var originalContent = Encoding.UTF8.GetString(errorHandlerFilter.OriginalBytesWritten.ToArray());</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  46:</span>             ErrorLog.GetDefault(context.Context).Log(<span style="color: #0000ff">new</span> Error(<span style="color: #0000ff">new</span> Exception(originalContent)));</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  47:</span>         }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  48:</span>     }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  49:</span>  </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  50:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>Notice in the <em>OnPostRequestHandlerExecute </em>function we’re intercepting any request that comes from a Webservice (.asmx page) and has a status code of greater than 400 (All error code types).&#160; At his point we want to set the ErrorHandelerFilter to the current Response.Filter value.</p>
<p>Now in the OnEndRequest function we want to get the current context and set the error handler based on the filter which should now be persisting the values we set in the previous function.&#160; Once we have the error values all we have to do is call the Elmah manual logging API and log the exception. </p>
<p>The final piece you have to do is set up the webConfig to recognize and use your I<em>HttpModule </em>code. n In your config file navigate down to System.Web &gt;&gt; HttpModules and fill in the attribute accordingly.</p>
<div>
<div>
<pre><span style="color: #606060">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">system.web</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   2:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">httpModules</span><span style="color: #0000ff">&gt;</span>    </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   3:</span>       <span style="color: #0000ff">&lt;</span><span style="color: #800000">add</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;ElmahExtension&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;Namespace.ElmahExtension.ElmahExtension&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   4:</span>     <span style="color: #0000ff">&lt;/</span><span style="color: #800000">httpModules</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   5:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">system.web</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>Once you compile and run, any errors encountered in your web services should now be logged by Elmah just like any others.</p>
<p>&#160;</p>
<p>Thanks to Reddy Kadasani, Mike Gerety and Dylan Barrett for their contributions to this solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/02/03/automatically-log-errors-with-elmah-in-script0service-webservice-calls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Two more tools for your bag of T-SQL tricks</title>
		<link>http://blog.tallan.com/2012/02/01/two-more-tools-foryour-bag-of-t-sql-tricks/</link>
		<comments>http://blog.tallan.com/2012/02/01/two-more-tools-foryour-bag-of-t-sql-tricks/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 13:26:35 +0000</pubDate>
		<dc:creator>gwilliams</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=2101</guid>
		<description><![CDATA[Have you ever been writing a new view and had the need to use an ORDER BY only to be greeted by an error message when you go to create the view.  Never fear, there is a solution. ORDER BY can only be used in views, inline functions, derived tables, sub-queries, and common table [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever been writing a new view and had the need to use an ORDER BY only to be greeted by an error message when you go to create the view.  Never fear, there is a solution. ORDER BY can only be used in views, inline functions, derived tables, sub-queries, and common table expressions if the keywords TOP or FOR XML are used. Thus we can either use TOP or FOR XML to get our solution. We will on talk about the TOP Keyword today and save FOR XML for another time.</p>
<p>TOP allows you to select the first ‘n’ records returned from a select. Consider the following table of s</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/02/01/two-more-tools-foryour-bag-of-t-sql-tricks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calling an ASP.Net web service using jQuery and JSON.</title>
		<link>http://blog.tallan.com/2012/01/29/calling-an-asp-net-web-service-using-jquery-and-json/</link>
		<comments>http://blog.tallan.com/2012/01/29/calling-an-asp-net-web-service-using-jquery-and-json/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 19:09:27 +0000</pubDate>
		<dc:creator>Karl Schwirz</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Enterprise .NET]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/2012/01/29/calling-an-asp-net-web-service-using-jquery-and-json/</guid>
		<description><![CDATA[Let’s say you have a webpage where you need to call a service but cannot perform a post back.&#160; Recently I was on a client engagement where we needed to improve page performance by dynamically loading a navigation tree with a potential for several thousand links.&#160; We implemented a solution that would load each branch [...]]]></description>
			<content:encoded><![CDATA[<p>Let’s say you have a webpage where you need to call a service but cannot perform a post back.&#160; Recently I was on a client engagement where we needed to improve page performance by dynamically loading a navigation tree with a potential for several thousand links.&#160; We implemented a solution that would load each branch as the user clicked on the expanding icon by calling a web service via ajax and passing the required links back to the page and render them client side.&#160; This saved immensely on the load time for the page and improved the user experience </p>
<p>This kind of solution can be applied to several situations such as complex data processing, dynamic loading, or combining them all into a seamless form submission process that would clear the form on post backs. </p>
<p>We can accomplish this process simply by grabbing an event, such as a button click, and collecting all the required information using jQuery.&#160; Next using a JSON call, we can pass all the parameters to the web service and execute our code from there.</p>
<p>Here, I’ll start with a simple .aspx page with jquery, a textbox, and link that will be used to call the web service.</p>
<div>
<div>
<pre><span style="color: #606060">   1:</span> <span style="background-color: #ffff00">&lt;%@ Master Language=&quot;C#&quot; MasterPageFile=&quot;~/Site.Master&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;ThisPage.cs&quot; Inherits=&quot;ThisSolution.ThisProject.ThisFolder&quot; %&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   2:</span>  </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   3:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">asp:Content</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">=&quot;Content1&quot;</span> <span style="color: #ff0000">ContentPlaceHolderID</span><span style="color: #0000ff">=&quot;HeadContent&quot;</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">=&quot;server&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   4:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">script</span> <span style="color: #ff0000">src</span><span style="color: #0000ff">=&quot;/Scripts/jquery-1.4.1.min.js&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;text/javascript&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   5:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">asp:Content</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   6:</span>  </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   7:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">asp:Content</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">=&quot;Content2&quot;</span> <span style="color: #ff0000">ContentPlaceHolderID</span><span style="color: #0000ff">=&quot;MainContent&quot;</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">=&quot;server&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   8:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">asp:TextBox</span> <font color="#ff0000">ID</font>=”<font color="#0000ff">textBox</font>” <span style="color: #ff0000">TextMode</span><span style="color: #0000ff">=&quot;MultiLine&quot;</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">=&quot;server&quot;</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">asp:TextBox</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre>

<span style="color: #606060">   9:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">a</span> <span style="color: #ff0000">href</span><span style="color: #0000ff">=&quot;#&quot;</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&quot;buttonClass&quot;</span><span style="color: #0000ff">&gt;</span> Save <span style="color: #0000ff">&lt;/</span><span style="color: #800000">a</span><span style="color: #0000ff">&gt;</span>

<span style="color: #0000ff">  <font color="#a5a5a5">10</font>:     <span style="color: #0000ff">&lt;</span><span style="color: #800000">asp:Label</span> <font color="#ff0000">ID</font>=”<font color="#0000ff">successLabel</font>” <span style="color: #ff0000">runat</span><span style="color: #0000ff">=&quot;server&quot;</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">asp:Label</span><span style="color: #0000ff">&gt;</span></span>
</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  11:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">asp:Content</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>Next, you will need to establish your web service and create an .asmx file.&#160; There are a couple of important things to note here. Line 5 will be by default commented out.&#160; So in order for us to make our JSON call we’re going to need this <em>uncommented</em>.&#160; Also, notice I’m returning a string.&#160; For the purposes of this demo I am going to return a string to the UI and display a message, but you can return any kind of object that can be serialized down to a primitive data type.</p>
<div>
<div>
<pre><span style="color: #606060">   1:</span> [WebService(Namespace = <span style="color: #006080">&quot;http://tempuri.org/&quot;</span>)]</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   2:</span> [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   3:</span> [System.ComponentModel.ToolboxItem(<span style="color: #0000ff">false</span>)]</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   4:</span> <span style="color: #008000">// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. </span></pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   5:</span> [System.Web.Script.Services.ScriptService]</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   6:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> wService : System.Web.Services.WebService</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   7:</span> {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   8:</span>     [WebMethod()]</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   9:</span>     [ScriptMethod(UseHttpGet = <span style="color: #0000ff">false</span>, ResponseFormat = ResponseFormat.Json)]</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  10:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> UpdateComment(<span style="color: #0000ff">string</span> textBoxText)</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  11:</span>     {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  12:</span>         var success = Service.CallToDb(textBoxText);</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  13:</span>  </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  14:</span>         <span style="color: #0000ff">if</span>(success)</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  15:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  16:</span>             <span style="color: #0000ff">return</span> <span style="color: #006080">&quot;Call to Database using text was successful&quot;</span>;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  17:</span>         }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  18:</span>         <span style="color: #0000ff">else</span> </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  19:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  20:</span>             <span style="color: #0000ff">return</span> <span style="color: #006080">&quot;Call to Database using text was not successful&quot;</span>;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  21:</span>         }    </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  22:</span>     }           </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  23:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>I use a jQuery selector to pick up on the mouse click of the link and gather our data into an javascript object.&#160; Note that when passing parameters through this object you have to name them the same way as you do in the parameter declaration of the web service.</p>
<p>When setting up the call to the service you’re going to want to remember to call the “JSON.stringify” function on your data object so that it serializes properly and that your contentType as well as dataType are configured properly as well.</p>
<div>
<div>
<pre><span style="color: #606060">   1:</span> &lt;script type=<span style="color: #006080">'text/javascript&gt;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   2:</span>     $('</span>.buttonClass<span style="color: #006080">').live('</span>click<span style="color: #006080">', function(){</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   3:</span>         var text = $('</span>#textBox<span style="color: #006080">').text();</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   4:</span>         var data = new Object();</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   5:</span>         data.textBoxText = text;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   6:</span>  </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   7:</span>         $.ajax({</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   8:</span>             type: &quot;POST&quot;,</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">   9:</span>             url: &quot;/Ajax/WbServcie.asmx/UpdateComment&quot;,</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  10:</span>             data: JSON.stringify(data),</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  11:</span>             contentType: &quot;application/json; charset=utf-8&quot;,</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  12:</span>             dataType: &quot;json&quot;,</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  13:</span>             success: function(msg){</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  14:</span>                 $('</span>#successLabel<span style="color: #006080">').val(msg);</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  15:</span>             },</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  16:</span>             error: function(msg){</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  17:</span>                 alert('</span>Something, somewhere, has gone terribly wrong');</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  18:</span>                 <span style="color: #0000ff">return</span> <span style="color: #0000ff">false</span>;</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  19:</span>             }</pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  20:</span>         });    </pre>
<p><!--CRLF--></p>
<pre><span style="color: #606060">  21:</span> &lt;/script&gt;</pre>
<p><!--CRLF--></div>
</div>
<p>Once you get a response from the service, you can set any of your data that is returned.&#160; In this case, we’re returning a string indicating the call to the database was successful and will set a label on the page to show that.</p>
<p>And that’s it.&#160; With just a few simple configurations we have a quick call back to the server without having to run an expensive post back. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/01/29/calling-an-asp-net-web-service-using-jquery-and-json/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mobile Site Development becoming as important as Desktop.</title>
		<link>http://blog.tallan.com/2012/01/25/mobile-site-development-becoming-as-important-as-desktop/</link>
		<comments>http://blog.tallan.com/2012/01/25/mobile-site-development-becoming-as-important-as-desktop/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 22:12:39 +0000</pubDate>
		<dc:creator>Karl Schwirz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/2012/01/25/mobile-site-development-becoming-as-important-as-desktop/</guid>
		<description><![CDATA[In recent years, the boom in mobile devices has caused more and more users to abandon their desktop internet browsers and opt for the ones sitting in their pocket. As a result, nearly 10% of 2011’s internet traffic was attributed to mobile device browsers. As more people are browsing the internet in this manner, it [...]]]></description>
			<content:encoded><![CDATA[<p>In recent years, the boom in mobile devices has caused more and more users to abandon their desktop internet browsers and opt for the ones sitting in their pocket. As a result, nearly 10% of 2011’s internet traffic was attributed to mobile device browsers. As more people are browsing the internet in this manner, it is important that currently standing websites, as well as newly developed ones, also include mobile friendly pages in their site.</p>
<p>Many companies have followed models put forth by sites such as <a href="http://www.amazon.com">www.amazon.com</a>, with their widely known desktop interface for purchasing products. When the mobile markets started to pick up they developed a mobile site that operates in much the same way, but offers a friendlier user experience for those viewing it on a smartphone screen. This move to a mobile intuitive platform can generate an increase in traffic and user engagement with the site by up to 85%.</p>
<p><a href="http://blog.tallan.com/wp-content/uploads/2012/01/clip_image001.png"><img style="border-bottom: 0px;border-left: 0px;margin: 0px 0px 18px;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px" border="0" alt="clip_image001" src="http://blog.tallan.com/wp-content/uploads/2012/01/clip_image001_thumb.png" width="536" height="273" /></a></p>
<p>A push to a mobile platform such as this doesn’t have to be expensive either. On a recent client engagement, I developed a mobile version of their desktop website that was established prior to my arrival. While building the mobile pages I was able to reuse a lot of the code behind, but with some simple device detection logic I finished the project a lot sooner and cheaper than if I had to develop a new site form square one.</p>
<p>Currently, 1 in 4 mobile devices are smartphones, and with the relatively low incremental development cost, and the prospect that mobile device users will overtake the number of desktop casual browsers by 2014, the importance of developing mobile friendly sites in tandem with their desktop versions will increase and will be a great benefit to any client with public facing websites. </p>
<p>Mobile usage statistics courtesy of <a href="http://blog.kissmetrics.com/mobile-mania/">KissMetrics</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/01/25/mobile-site-development-becoming-as-important-as-desktop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSIS FTP Task</title>
		<link>http://blog.tallan.com/2012/01/23/ssis-ftp-task/</link>
		<comments>http://blog.tallan.com/2012/01/23/ssis-ftp-task/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 15:35:05 +0000</pubDate>
		<dc:creator>nrubino</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=2078</guid>
		<description><![CDATA[ Experience 1 : No ServerPassword? 
The client required a scheduled transfer of multiple TIF files from one server to another over FTP.  Since this task was initially implemented using SSIS, the change seemed to be trivial; I would create a new FTP Connection in the job’s Connection Manager window and replace the current copy task (a [...]]]></description>
			<content:encoded><![CDATA[<div><strong> </strong><strong>Experience 1 : No ServerPassword? </strong></div>
<div>The client required a scheduled transfer of multiple TIF files from one server to another over FTP.  Since this task was initially implemented using SSIS, the change seemed to be trivial; I would create a new FTP Connection in the job’s Connection Manager window and replace the current copy task (a Script Task using System.IO functions) with an FTP task inside a For Each Loop to iterate over each file, copying them one by one to the FTP server.<strong> </strong></div>
<div><strong> </strong></div>
<div><strong> </strong></div>
<div><strong> </strong></div>
<div><strong></strong></div>
<p><strong></p>
<div class="wp-caption alignnone" style="width: 275px"><a href="http://blog.tallan.com/wp-content/uploads/2012/01/ftpTask.jpg"><img src="http://blog.tallan.com/wp-content/uploads/2012/01/ftpTask.jpg" alt="" width="265" height="308" /></a><p class="wp-caption-text">The &quot;Set FTP Paths&quot; Script Task sets path variables that the FTP Task uses.</p></div>
<p><a href="http://blog.tallan.com/wp-content/uploads/2012/01/serverPassword.jpg"></a></p>
<p></strong></p>
<p>After a few “trial and error”s due to some changes in the parameters the process ran successfully in debug mode from my local computer.  Happy that I had completed the task, I started the deployment to our QA server so that I could test a scheduled instance of the job.  This is where I ran into a bit of a headache.</p>
<p>Deployment consisted of creating a configuration file (.dtsConfig file) with all the specific parameters, copying this along with the job file up to the server, and scheduling the job using the config file in Jobs under SQL Server Agent of SQL Server Management Studio.  After getting through a few environment errors related to the configuration file, I found the following error in my log.</p>
<p><span style="color: #ff0000">&#8220;An Error occurred in the requested FTP operation. Detailed error description: The password was not allowed.&#8221;</span></p>
<p>After a bit of troubleshooting I finally realized the password in the Connection String that I was setting using an expression in the FTP Connection was not being carried over correctly to my QA server.  In fact neither was the Username and the only reason the job was running correctly on my local computer was that I had manually set the values into the FTP Manager Connection Editor window when I initially created the FTP Connection.  I then went on to try to set the Username and Password specifically in the Expression Editor for the FTP Connection.  As you can see in the below screen shot, SSIS lets you set the Username (ServerUserName) but does not let you set the Password for an FTP Server.</p>
<div class="wp-caption alignnone" style="width: 310px"><a href="http://blog.tallan.com/wp-content/uploads/2012/01/serverPassword.jpg"><strong><img class=" " src="http://blog.tallan.com/wp-content/uploads/2012/01/serverPassword-300x236.jpg" alt="" width="300" height="236" /></strong></a><p class="wp-caption-text">No ServerPassword!?</p></div>
<p>(As mentioned in the comment section of a link I reference below, it makes absolutely no sense for them to exclude this property considering the passwords for FTP transfers are sent in plain text .. but I wont get into that.)</p>
<p>The reason the job kept failing out on the QA server was that the Username and Password were not being included in the ConnectionString of the FTP Connection in the dtsConfig file. After a bit of internet searching I came across <a href="http://www.proteanit.com/b/2008/02/13/ssis-ftp-task-code-to-set-the-password/">this article</a>.  In it Frank goes over exactly what the problem was with my job; when you create an FTP Connection in SSIS you cannot set the password through a Connection String expression.  As he displays, one way to get around this is to write a Script Task and manually set the “ServerPassword” parameter with a hard coded string.</p>
<p><a href="http://www.sqlservergeeks.com/blogs/raunak.jhawar/sql-server-bi/398/sql-server-2012-ssis-sending-files-using-ftp-task">SSIS 2012 seems to use the FTP Task</a> so unless something changes, be ready to use this hack in your future SSIS packages using FTP.</p>
<p><strong>Experience 2 : What’s Thumbs.db?</strong></p>
<p>This experience was a little less frustrating than Experience 1 but still annoying.  For my specific package, after the FTP transfer is completed, there is validation performed that compares a count of how many files were supposed to be sent with how many files were actually sent.  This validation failed so I went out to the destination FTP server and found a file called Thumbs.db.  For whatever reason I did not use an expression to filter only the .TIF files I wanted from the source folder, and instead just took every file there assuming there would never be anything else in there.</p>
<p>The counts in the validation were off and were causing the job to fail due to the <a href="http://www.ofzenandcomputing.com/zanswers/98/">Thumbs.db</a> file Windows Server 2003 creates to show the thumbnails of images in a Windows explorer window.  This file is not visible when viewing the folder but the FTP process was picking it up and causing the validation to fail.  After adding a simple filter of *.TIF files, the process did not pick up the Thumbs.db and ran successfully.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/01/23/ssis-ftp-task/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Helpful Extension Method for Visibility in XAML</title>
		<link>http://blog.tallan.com/2012/01/21/creating-a-helpful-extension-method-for-visibility-in-xaml/</link>
		<comments>http://blog.tallan.com/2012/01/21/creating-a-helpful-extension-method-for-visibility-in-xaml/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 00:00:31 +0000</pubDate>
		<dc:creator>Lenni Lobel</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[User Experience Design]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visibility]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=1478</guid>
		<description><![CDATA[In this post, I’ll show you how to create an extension method for the bool class that will simplify your .NET code in XAML-based apps (either WPF or Silverlight). In particular, this extension method addresses the fact that the Visibility property of UI controls in XAML is not a Boolean (true/false) value (as has traditionally [...]]]></description>
			<content:encoded><![CDATA[<p>In this post, I’ll show you how to create an extension method for the <em>bool</em> class that will simplify your .NET code in XAML-based apps (either WPF or Silverlight). In particular, this extension method addresses the fact that the <em>Visibility </em>property of UI controls in XAML is not a Boolean (true/false) value (as has traditionally been the case for both Windows Forms and ASP.NET). Instead, it’s one of three possible enumerated constant values: <em>Hidden</em>, <em>Collapsed</em>, and <em>Visible</em>.</p>
<p><em>Visible</em> obviously means “visible,” while both <em>Hidden</em> and <em>Collapsed </em>mean “invisible.” The difference between <em>Hidden</em> and <em>Collapsed</em> is merely whether or not the invisible control occupies blank space on the screen that it would occupy if it were visible. <em>Collapsed</em> consumes no space, while <em>Hidden</em> does.</p>
<p>It’s nice to have the three options, but in most cases you’ll find that you just need the two options <em>Visible </em>and <em>Collapsed</em>. If you’re setting visibility to XAML controls using these two enums, you’ve probably noticed that it’s just not as clean as it is with Windows Forms or ASP.NET controls. You typically already have a Boolean value—either as a simple variable, or an expression—that determines whether the control should be visible or not. You could use that value to enable or disable the control, as the <em>IsEnabled</em> property is also a Boolean, but you can’t assign it to the <em>Visibility </em>property because that property expects one of the three <em>Visibility </em>enumerations—not a Boolean. That’s frustrating, because from a UX (user experience) perspective, where these concepts are used to convey “availability” to the user, hiding/showing controls versus enabling/disabling them is a subtlety of UI design. So developers should be able to think (and code) freely in terms of Booleans for both <em>IsEnabled</em> and <em>Visibility</em>.</p>
<p>Consider the C# code to manipulate the <em>Visibility</em> and <em>IsEnabled</em> properties of a button control:</p>
<pre style="background-color: #fcfbe2;border: solid 1px black;padding: 8px">OpenCustomerButton.IsEnabled = <span style="color: blue">false</span>;
OpenCustomerButton.IsEnabled = <span style="color: blue">true</span>;
OpenCustomerButton.Visibility = <span style="color: #2b91af">Visibility</span>.Collapsed;
OpenCustomerButton.Visibility = <span style="color: #2b91af">Visibility</span>.Visible;

<span style="color: blue">bool</span> isAvailable = <span style="color: blue">true</span>;
OpenCustomerButton.IsEnabled = isAvailable;
OpenCustomerButton.Visibility =
  (isAvailable ? <span style="color: #2b91af">Visibility</span>.Collapsed : <span style="color: #2b91af">Visibility</span>.Visible);

<span style="color: #008014">// Set the visibility according another button's enabled/disabled state</span>
OpenCustomerButton.Visibility =
  (ManageCustomersButton.IsEnabled ? <span style="color: #2b91af">Visibility</span>.Visible : <span style="color: #2b91af">Visibility</span>.Collapsed);</pre>
<p>You can see that because <em>Visibility </em>takes the enum rather than a <em>bool</em>, it’s harder to work with than <em>IsEnabled</em>, and just isn’t as neat. But we can do something about this. How? By writing a simple (one-line!) extension method that adds a <em>ToVisibility </em>method to the <em>bool </em>class:</p>
<pre class="brush: plain;">public static class BoolExtensions
{
  public static Visibility ToVisibility(this bool isVisible)
  {
    return (isVisible ? Visibility.Visible : Visibility.Collapsed);
  }
}</pre>
<p>Now the same UI code is much easier to read and write:</p>
<pre style="border: 1px solid black;background-color: #fcfbe2;padding: 8px">OpenCustomerButton.IsEnabled = <span style="color: blue">false</span>;
OpenCustomerButton.IsEnabled = <span style="color: blue">true</span>;
OpenCustomerButton.Visibility = <span style="color: blue">false</span><span style="background-color: yellow">.ToVisibility()</span>;
OpenCustomerButton.Visibility = <span style="color: blue">true</span><span style="background-color: yellow">.ToVisibility()</span>;

<span style="color: blue">bool</span> isAvailable = <span style="color: blue">true</span>;
OpenCustomerButton.IsEnabled = isAvailable;
OpenCustomerButton.Visibility = isAvailable<span style="background-color: yellow">.ToVisibility()</span>;

<span style="color: #008014">// Set the visibility according to another button's enabled/disabled state</span>
OpenCustomerButton.Visibility = ManageCustomersButton.IsEnabled<span style="background-color: yellow">.ToVisibility()</span>;</pre>
<p>Like? Me too. Neatness counts!</p>
<p>It would be even better if we could instead extend every <em>UIElement </em>with a Boolean <em>property </em>called <em>IsVisible</em>, and embed the conversion logic bi-directionally in the property&#8217;s getter and setter. But, unfortunately, you cannot create extension properties in .NET, only extension methods. So extending <em>bool</em> with a <em>ToVisibility</em> method is the next best thing.</p>
<p>One more tip: Put the <em>BoolExtensions </em>class inside a common code namespace that all your XAML classes import, so <em>ToVisibility</em> is always available without needing to add an extra <em>using </em>statement.</p>
<p>Remember, abusing extension methods quickly leads to messy, buggy code. Instead, find appropriate uses for extension methods that yield cleaner, tighter code.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/01/21/creating-a-helpful-extension-method-for-visibility-in-xaml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Overriding jQuery Functions</title>
		<link>http://blog.tallan.com/2012/01/18/overriding-jquery-functions/</link>
		<comments>http://blog.tallan.com/2012/01/18/overriding-jquery-functions/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 13:23:33 +0000</pubDate>
		<dc:creator>Thomas Oscarson</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=2057</guid>
		<description><![CDATA[In my last post I showed how to create a localized instance of jQuery that performed custom selection by handling ID selectors in a specific way.  There are other parts of jQuery though that can have IDs passed in for arguments, such as the find and children functions.  These functions can also be [...]]]></description>
			<content:encoded><![CDATA[<p>In my last post I showed how to create a localized instance of jQuery that performed custom selection by handling ID selectors in a specific way.  There are other parts of jQuery though that can have IDs passed in for arguments, such as the find and children functions.  These functions can also be customized to override the default behavior as well.  In this example, if the find and children functions are left unchanged, they will fail find any elements by ID if we don’t include the end part of the ID that we append in the $$ function.  So let’s look at overriding / extending the find function.</p>
<pre class="brush: jscript;">
// Extended .find(selector) to append the _elementId to any
    // ID selector (containing &quot;#&quot;)
    (function ($$) {
        var originalFind = $.fn.find;
        $$.fn.find = function (selector) {
            selector = getFullSelectorIds(selector);
            return originalFind.call(this, selector);
        };
    })(jQuery);
</pre>
<p>In the above code we are using a self-executing function to replace jQuery’s find function (specifically for the $$ instance, not the default instance).  In this example we do not want to completely remove the original find function, since we do want to use it, we just need to do some preprocessing of the selector.  What we do is store a copy of the original, (in originalFind) and then we replace find with our new one.  The new one works just like the $$ function in my previous post, only we just have the one argument to process.  Then to actually perform the find, we call the originalFind using the processed selector.<br />
Of course this is just one specific case, but any of the built-in jQuery functions can be overridden in the same way.  Likewise this is how one would add completely new functionality to jQuery.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/01/18/overriding-jquery-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Customizing the Default jQuery Selector Behavior</title>
		<link>http://blog.tallan.com/2012/01/17/customizing-the-default-jquery-selector-behavior/</link>
		<comments>http://blog.tallan.com/2012/01/17/customizing-the-default-jquery-selector-behavior/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 13:40:27 +0000</pubDate>
		<dc:creator>Thomas Oscarson</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=2044</guid>
		<description><![CDATA[jQuery on its own is a great JavaScript library that makes a lot of tasks simpler and easier.  Although as easy as it is you may find yourself needing to work within a restricted scope and not constantly wanting to have to include the context for every selector.  This exact case happened on our project. [...]]]></description>
			<content:encoded><![CDATA[<p>jQuery on its own is a great JavaScript library that makes a lot of tasks simpler and easier.  Although as easy as it is you may find yourself needing to work within a restricted scope and not constantly wanting to have to include the context for every selector.  This exact case happened on our project.  We had the need to change from supporting just a single instance of a rather complex user control with a large amount of JavaScript, to having several instances of this control on the same page.  The JavaScript for this control utilized jQuery selectors all over the code, making it fairly tedious to accomplish without some help.   To make things easier we needed to restrict jQuery to the specific container that holds the instance of the control that we are interested in.  Now one way to do that would be to simply pass the context into the jQuery selector.</p>
<p>So something like this:  $(‘myselector’) would become $(‘myselector’, context), with context = $(‘mycontrolscontainer’).</p>
<p>Now that certainly would work, but with a large number or selectors in the controls JavaScript it can take quite a long time to replace all of these.</p>
<p>Instead of changing every jQuery selector, we can instead create a private jQuery instance, that automatically uses the correct context.  First we need to assume that each of these controls on the page is limited to the scope of its instance.  Within this you need to define a new variable for the instance specific jQuery, lets call it $$:</p>
<pre class="brush: jscript;">
var $$ = function (selector, context) {
        selector = getFullSelectorIds(selector);
        context = getFullSelectorIds(context);
        return $(selector, context);
    };
</pre>
<p>This function $$, takes in a selector and a context, just like the normal $ function, however it does some extra work, using another function “getFullSelectorIds” which takes in either the selector or the context.  Then it uses the output of that function to pass into the normal $ function, which behaves just as it always had.</p>
<pre class="brush: jscript;">
function getFullSelectorIds(selector) {
        // Selector string (looking for id(s)), check for _elementId appended
        if (typeof selector == &quot;string&quot; &amp;&amp; selector.indexOf(&quot;#&quot;) != -1) {
            var ids = selector.split(&quot;,&quot;);
            var len = ids.length;
            for (var i = 0; i &amp;lt; len; i++) {
                // Looking for id
                // _elementId is not appended, so add it
                if (ids[i].indexOf(&quot;#&quot;) != -1 &amp;&amp; ids[i].indexOf(_elementId) == -1) {
                    var subIds = ids[i].split(&quot;:&quot;);
                    subIds[0] = subIds[0] + _elementId;
                    ids[i] = subIds.join(':');
                }
                // _elementId is already appended or not looking for id in this one, no change
            }
            selector = ids.join(&quot;,&quot;);
        }
        return selector;
    }
</pre>
<p>The “getFullSelectorIds” function is the part that is special and will vary depending on your needs.  For our project we append a certain string to the end of all the IDs in the control.  This allows the IDs for the same part of each control instance to start with the same ID but end with the control specific one.  What we do here is append the _elementId string to any selectors that are string types, which are selecting based on ID’s (evidenced by the string containing “#”).  We also handle the  case where you have a comma separated list of selectors (that may be a mix of IDs, classes and others).</p>
<p>Now that we have the $$ function and the getFullSelectorIds function (which does all the real work), we are still not quite done.  Currently our $$ function is missing a number of nice jQuery functions.  To copy all of them over into the $$ we need to do the following:</p>
<pre class="brush: jscript;">
$$.fn = $$.prototype = jQuery.fn;
jQuery.extend($$, jQuery); // copy's trim, extend, find, etc to $$
</pre>
<p>What this does is copy the jQuery prototype into the  prototype of $$.  Now the last step is to use it.  To use it all we need to do is replace any instances of $ with $$ and we are done.  Of course you can still use the regular $ function anywhere you want with no change to its functionality, or when you need to be scoped to within a specific control, just use that control’s $$.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/01/17/customizing-the-default-jquery-selector-behavior/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting Up Azure Deployment Certificates</title>
		<link>http://blog.tallan.com/2012/01/16/setting-up-azure-deployment-certificates/</link>
		<comments>http://blog.tallan.com/2012/01/16/setting-up-azure-deployment-certificates/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 23:43:37 +0000</pubDate>
		<dc:creator>Richard Krajunus</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=1850</guid>
		<description><![CDATA[Azure deployments can be integrated within Visual Studio 2010, making it easy for you to package, deploy and publish your solution to an Azure cloud.  This blog post will show you how to integrate your Azure deployments usingVisual Studio 2010 with an easy two step process.  First, you have to create a certificate within Visual [...]]]></description>
			<content:encoded><![CDATA[<p>Azure deployments can be integrated within Visual Studio 2010, making it easy for you to package, deploy and publish your solution to an Azure cloud.  This blog post will show you how to integrate your Azure deployments usingVisual Studio 2010 with an easy two step process.  First, you have to create a certificate within Visual Studio, and second, you have to configure your Azure environment to accept that certificate.</p>
<ol>
<li>To create a certificate, begin by right clicking your project in the Solution Explorer pane.<br />
<img class="alignnone size-full wp-image-1947" src="http://blog.tallan.com/wp-content/uploads/2012/01/PublishInContextMenu.png" alt="" width="530" height="577" /></li>
<li>Then, in the Credentials dropdown, select &lt;Manage&#8230;&gt;<br />
<a href="http://blog.tallan.com/wp-content/uploads/2012/01/ManageCredentials.png"><img class="alignnone size-full wp-image-1943" src="http://blog.tallan.com/wp-content/uploads/2012/01/ManageCredentials.png" alt="" width="420" height="478" /></a></li>
<li>Then, select New.<br />
<a href="http://blog.tallan.com/wp-content/uploads/2012/01/NewCredentialButton.png"><img class="alignnone size-full wp-image-1946" src="http://blog.tallan.com/wp-content/uploads/2012/01/NewCredentialButton.png" alt="" width="443" height="268" /></a></li>
<li>In the window that appears, 3 steps must be completed before proceeding.  To complete step 1, expand the first drop down and select Create&#8230; and create a certificate.  To complete step 2, click &#8220;Copy the full path&#8221;.  Now, we have to digress from this dialog box and cover the second part of our exercise (configuring the Azure portal to accept our certificate), before coming back to finish up here.<br />
<a href="http://blog.tallan.com/wp-content/uploads/2012/01/CredentialConfiguration.png"><img class="alignnone size-full wp-image-1942" src="http://blog.tallan.com/wp-content/uploads/2012/01/CredentialConfiguration.png" alt="" width="510" height="347" /></a></li>
<li>Login to the Windows Azure Portal, click Hosted Service, Storage Accounts &amp; CDN, then click Management Certificates.  Click Add Certificate, (upper left) which opens a dialog box.  Paste the path to the certificate path (the certificate path was put in the clipboard during Step 4) in the dialog box, and then click OK.<br />
<img class="alignnone size-full wp-image-2040" src="http://blog.tallan.com/wp-content/uploads/2012/01/ManagementCertificatesSubscriptionId.png" alt="" width="905" height="894" /></p>
<p><img src="http://blog.tallan.com/wp-content/uploads/2012/01/AddCertificateLightBox.png" alt="" width="689" height="281" /></li>
<li>Copy the Subscription ID from the field as show above.  The ID has been censored in the screenshot in the screenshot, but will appear as a hexadecimal string similar to the example ID shown in Step 4.</li>
<li>Paste the Subscription ID into the dialog box from Step 4, and click OK.</li>
</ol>
<p>To deploy your application to the Azure cloud from within Visual Studio, right click your project and select Publish (same as Step 1).  In the dialog box that appears (shown in Step 2) click Publish.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/01/16/setting-up-azure-deployment-certificates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Look at How to Migrate an Access Database to SQL Server Part 1 of 2</title>
		<link>http://blog.tallan.com/2012/01/16/a-look-at-how-to-migrate-an-access-database-to-sql-server-part-1-of-2/</link>
		<comments>http://blog.tallan.com/2012/01/16/a-look-at-how-to-migrate-an-access-database-to-sql-server-part-1-of-2/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 09:00:15 +0000</pubDate>
		<dc:creator>kmorillo</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Access]]></category>
		<category><![CDATA[Access 2010]]></category>
		<category><![CDATA[Microsoft Access]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>
		<category><![CDATA[Migration]]></category>
		<category><![CDATA[SQL Server 2008 R2]]></category>

		<guid isPermaLink="false">http://blog.tallan.com/?p=1964</guid>
		<description><![CDATA[Recently I was tasked with migrating a Microsoft Access 2010 database to SQL Server 2008 R2 while preserving the form functionality built into Access.  While the migration using Microsoft Access’ ‘Upsizing Wizard’ was easy enough for a majority of the objects, I found that a few of the more complex Access queries and tables needed [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was tasked with migrating a Microsoft Access 2010 database to SQL Server 2008 R2 while preserving the form functionality built into Access.  While the migration using Microsoft Access’ ‘Upsizing Wizard’ was easy enough for a majority of the objects, I found that a few of the more complex Access queries and tables needed manipulation or outright manual conversion to objects that both SQL Server and Access agreed with.  In this two part blog series I will go through how to use the upsizing wizard to migrate an Access mdb file to an Access Project file connected to a SQL Server backend.  In the second part of this series I will go over some possible roadblocks and issues that could arise, as well as their solutions.</p>
<p>This sample application will have a a simple form opening two parameterized queries, one of which having a few columns formatted as lookups to other tables.  We will be migrating both tables and queries, while retaining the form and and VBA code tied to the form.</p>
<ul>
<li>First we will open the the sample access_to_sql_tutorial.mdb file and select the ‘SQL Server’ button in the ‘Move Data’ group of the  ‘Database Tools’ Tab.</li>
</ul>
<blockquote><p><strong>Note</strong>: Make sure there are no forms or objects open when using the Upsizing Wizard, as those objects may fail to be migrated to SQL Server.</p></blockquote>
<blockquote><p><a href="http://blog.tallan.com/wp-content/uploads/2012/01/image8.png"><img style="margin: 0px 0px 18px;padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px" src="http://blog.tallan.com/wp-content/uploads/2012/01/image_thumb8.png" border="0" alt="image" width="424" height="294" /></a></p></blockquote>
<ul>
<li>Select ‘Create New Database’, then select ‘Next’.</li>
<li>Enter the destination SQL Server name and instance name, and name the database to be created.  Select ‘Next’.</li>
</ul>
<blockquote><p><a href="http://blog.tallan.com/wp-content/uploads/2012/01/image9.png"><img style="margin: 0px 0px 18px;padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px" src="http://blog.tallan.com/wp-content/uploads/2012/01/image_thumb9.png" border="0" alt="image" width="424" height="317" /></a></p></blockquote>
<ul>
<li>The next screen will prompt to select the tables to export and link to SQL Server.  Select the relevant tables then select ‘Next’.</li>
</ul>
<blockquote><p><a href="http://blog.tallan.com/wp-content/uploads/2012/01/image10.png"><img style="margin: 0px 0px 18px;padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px" src="http://blog.tallan.com/wp-content/uploads/2012/01/image_thumb10.png" border="0" alt="image" width="424" height="314" /></a></p></blockquote>
<ul>
<li>The default values in the next screen should be sufficient for simple migrations.  The only option which may be relevant would be the checkbox: ‘Only create the table structure; don’t upsize any data’.  Select ‘Next’.</li>
</ul>
<blockquote><p><a href="http://blog.tallan.com/wp-content/uploads/2012/01/image11.png"><img style="margin: 0px 0px 18px;padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px" src="http://blog.tallan.com/wp-content/uploads/2012/01/image_thumb11.png" border="0" alt="image" width="424" height="314" /></a></p></blockquote>
<ul>
<li>In the next screen, you will get the option to either link all of the tables to SQL Server to the existing application (mdb), or create a new ‘Access Project’ file which truly functions as a client / server application.  For this tutorial we will go with the later option ‘Create a New Access client/ server application’.  Give the new application a name and click ‘Next’</li>
</ul>
<blockquote><p><a href="http://blog.tallan.com/wp-content/uploads/2012/01/image12.png"><img style="margin: 0px 0px 18px;padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px" src="http://blog.tallan.com/wp-content/uploads/2012/01/image_thumb12.png" border="0" alt="image" width="424" height="314" /></a></p></blockquote>
<ul>
<li>If prompted if you want to save an unencrypted password select ‘yes’.  For the purposes of this simple demo we will not worry too much about security.  Though there are many security options available for Access Project (adp) project types, for more information on the security features available in Microsoft Access go to: <a href="http://office.microsoft.com/en-us/access-help/introduction-to-access-2010-security-HA010341741.aspx">http://office.microsoft.com/en-us/access-help/introduction-to-access-2010-security-HA010341741.aspx</a></li>
</ul>
<blockquote><p><a href="http://blog.tallan.com/wp-content/uploads/2012/01/image13.png"><img style="margin: 0px 0px 18px;padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px" src="http://blog.tallan.com/wp-content/uploads/2012/01/image_thumb13.png" border="0" alt="image" width="464" height="96" /></a></p></blockquote>
<ul>
<li>In the next screen you can choose to either open the new adp file (if you selected the option to create a new project file in the previous screen), or keep the current pre migrated access file open.  Select ‘Finish’.</li>
<li>The next screen will show the progress of migrating to SQL Server.</li>
</ul>
<blockquote><p><a href="http://blog.tallan.com/wp-content/uploads/2012/01/image14.png"><img style="margin: 0px 0px 18px;padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px" src="http://blog.tallan.com/wp-content/uploads/2012/01/image_thumb14.png" border="0" alt="image" width="354" height="140" /></a></p></blockquote>
<ul>
<li>When completed, you will be prompted with the Migration report which will list every object migrated and the migration status.</li>
</ul>
<blockquote><p><a href="http://blog.tallan.com/wp-content/uploads/2012/01/image15.png"><img style="margin: 0px 0px 18px;padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px" src="http://blog.tallan.com/wp-content/uploads/2012/01/image_thumb15.png" border="0" alt="image" width="424" height="314" /></a></p></blockquote>
<ul>
<li>After the migration has finished you will be brought to the adp project.  You can now go into SQL Server Management Studio and verify the new SQL Server database has been created.</li>
</ul>
<blockquote><p><a href="http://blog.tallan.com/wp-content/uploads/2012/01/image16.png"><img style="padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px" src="http://blog.tallan.com/wp-content/uploads/2012/01/image_thumb16.png" border="0" alt="image" width="304" height="364" /></a></p></blockquote>
<ul>
<li>You can see from the list of database objects that the tables have been successfully migrated,  though the ‘PRODUCT DATA’ query has not.  Simple non parameterized queries are migrated as views in SQL Server, though since this query used parameters it would have to be migrated as am stored procedure or table-valued function.</li>
</ul>
<p>In the next blog post in the series I will discuss how to migrate the parameterized ‘PRODUCT DATA’ Access query to a compatible table-valued query in SQL Server, and I will also go into possible pitfalls and roadblocks that may appear during migration.</p>
<p><strong>Note</strong>: Attached to this article is the sample Access 2010 application used during this tutorial.</p>
<div class="wlWriterSmartContent" style="margin: 0px;float: none;padding: 0px">
<p><a href="http://blog.tallan.com/wp-content/uploads/2012/01/access_to_sql_tutorial.zip" target="_blank">Access mdb database file</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.tallan.com/2012/01/16/a-look-at-how-to-migrate-an-access-database-to-sql-server-part-1-of-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

