<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Linvi</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/timart/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/timart/feed.xml</link>
    <description />
    <lastBuildDate>Tue, 07 Apr 2015 20:06:55 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>DispatcherUnhandledException catches children window Exception before try catch (ShowDialog)</title>
      <link>https://docs.microsoft.com/archive/blogs/timart/dispatcherunhandledexception-catches-children-window-exception-before-try-catch-showdialog</link>
      <pubDate>Mon, 30 Sep 2013 09:08:00 GMT</pubDate>
      <dc:creator><![CDATA[linvỉ]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/timart/2013/09/30/dispatcherunhandledexception-catches-children-window-exception-before-try-catch-showdialog/</guid>
      <description><![CDATA[Problem
Application.DispatcherUnhandledException is a solution provided by the .NET Framework to...]]></description>
      <content:encoded><![CDATA[<h1><span style="font-size: x-large;"><span style="font-family: Times New Roman;">Problem</span></span></h1>
<p><span style="color: #0000ff;">Application</span>.<span style="color: #ff00ff;">DispatcherUnhandledException</span> is a solution provided by the .NET Framework to manage any Unmanaged Exception bubbling up to the root of your application (App.AppStartup).</p>
<p>Whilst using this solution I faced a problem when opening new windows from the Dispatcher of the UI Thread. When performing a try/catch around a Window.ShowDialog(), the <span style="color: #ff00ff;">DispatcherUnhandledException</span> will be invoked before the try/catch.</p>
<p>This basically means that your root exception handler is used instead of higher try/catch. This also imply that using a multi-windowed application and using the <span style="color: #ff00ff;">DispatcherUnhandledException</span> does not allow you to properly managed any Exception as you will need to know where they come from.</p>
<h2><span style="font-size: medium;"><span style="color: #4f81bd;"><span style="font-family: Cambria;">Example</span></span></span></h2>
<p><strong><span style="color: #0000ff; text-decoration: underline;"><span style="font-size: small;">App.xaml.cs </span></span></strong></p>
<p><br />public App()<br />{<br />&nbsp;&nbsp;&nbsp; DispatcherUnhandledException += App_<span style="color: #ff00ff;">OnDispatcherUnhandledException</span>;<br />}</p>
<p>private void App_OnDispatcherUnhandledException(object <strong>sender</strong>, <span style="color: #ff00ff;">DispatcherUnhandledExceptionEventArgs </span><strong>e</strong>)<br />{<br />&nbsp;&nbsp;&nbsp; Console.WriteLine("Handler #1 An Exception occured in the Root (App.xaml.cs)");<br />}</p>
<p>&nbsp;<br /><strong><span style="color: #0000ff; text-decoration: underline;"><span style="font-size: small;">MainWindow.xaml.cs</span></span></strong></p>
<p>private void Button_Click(object <strong>sender</strong>, RoutedEventArgs <strong>e</strong>)<br />{<br />&nbsp;&nbsp;&nbsp; ErroringWindow <strong>window</strong> = new ErroringWindow();<br />&nbsp;&nbsp;&nbsp; try<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strong>window</strong>.ShowDialog();<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; catch (Exception)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine("Handler #2 Exception occured in the try/catch");<br />&nbsp;&nbsp;&nbsp; }<br />}</p>
<p>&nbsp;</p>
<p>You would expect the handler #2 to catch an Exception from the ErroringWindow first.</p>
<p><span style="text-decoration: underline;">But here is the result :</span></p>
<p>&gt; Handler #1 An Exception occured in the Root (App.xaml.cs)</p>
<p>&gt; Handler #2 Exception occured in the try/catch</p>
<h1><span style="font-size: x-large;"><span style="font-family: Times New Roman;">Solution</span></span></h1>
<p>The solution is very simple and straightforward. Using a try/catch around all the code of the App.Startup event will let the Exception bubble up the right way and let you manage the UnhandledExceptions in your try/catch.</p>
<p><strong><span style="color: #0000ff; text-decoration: underline;"><span style="font-size: small;">App.xaml</span></span></strong></p>
<p>Remove the <span style="color: #ff00ff;">StartupUri</span>="<span style="color: #0000ff;"><strong>MainWindow.xaml</strong></span>" from the App.xaml so that we invoke it in code.</p>
<p><strong><span style="color: #0000ff; text-decoration: underline;"><span style="font-size: small;">App.xaml.cs </span></span></strong></p>
<p>public App()<br />{<br />&nbsp;&nbsp;&nbsp; Startup += OnStartup;<br />}</p>
<p>private void OnStartup(object <strong>sender</strong>, StartupEventArgs <strong>startupEventArgs</strong>)<br />{<br />&nbsp;&nbsp;&nbsp; try<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MainWindow <strong>window</strong> = new MainWindow();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strong>window</strong>.ShowDialog();<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; catch (Exception <strong>ex</strong>)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ManageGlobalException(<strong>ex</strong>);<br />&nbsp;&nbsp;&nbsp; }<br />}</p>
<p>private void ManageGlobalException(Exception ex)<br />{<br />&nbsp;&nbsp;&nbsp; Console.WriteLine("An Exception occured in the Root (App.xaml.cs)");<br />}</p>
<p><span style="color: #0000ff;"><strong><span style="text-decoration: underline;"><span style="font-size: small;">MainWindow.xaml.cs</span></span></strong></span></p>
<p>&nbsp;private void Button_Click(object <strong>sender</strong>, RoutedEventArgs <strong>e</strong>)<br />{<br />&nbsp;&nbsp;&nbsp; ErroringWindow <strong>window</strong> = new ErroringWindow();<br />&nbsp;&nbsp;&nbsp; try<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strong>window</strong>.ShowDialog();<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; catch (Exception)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine("Handler #2 Exception occured in the try/catch");<br />&nbsp;&nbsp;&nbsp; }<br />}</p>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;">Result :</span></p>
<p>&gt; Exception occured in the try/catch</p>]]></content:encoded>
    </item>
    <item>
      <title>Nested/Recursive Regex and .NET Balancing Groups - Detect a function with a Regex</title>
      <link>https://docs.microsoft.com/archive/blogs/timart/nestedrecursive-regex-and-net-balancing-groups-detect-a-function-with-a-regex</link>
      <pubDate>Tue, 14 May 2013 04:52:00 GMT</pubDate>
      <dc:creator><![CDATA[linvỉ]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/timart/2013/05/14/nestedrecursive-regex-and-net-balancing-groups-detect-a-function-with-a-regex/</guid>
      <description><![CDATA[Problem Overview
Regex is a powerful tool allowing us to extract content from a string based on a...]]></description>
      <content:encoded><![CDATA[<h1 class="WordSection1">Problem Overview</h1>
<p class="MsoNormal">Regex is a powerful tool allowing us to extract content from a string based on a Regular Expression. When you need to identify a string that contains nested elements, it might be more difficult to understand how to create a Regex solving this specific problem.</p>
<p class="MsoNormal">Let&rsquo;s say you want to extract a specific function from a JavaScript file, how are you going to manage the nested braces of condition or loop...</p>
<p class="MsoNormal">This post will explain how to perform this operation with a simple Regex (in .NET).</p>
<p class="MsoNormal">Here is the input string:</p>
<p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">&nbsp;</p>
<pre style="background: white; color: black; font-family: Consolas; font-size: 10pt;">exampleChars<span style="color: #1e7c70;">*&amp;^%(((!</span>&pound;<span style="color: #1e7c70;">)!)</span>_<span style="color: #1e7c70;">*</span>$<span style="color: #1e7c70;">)({}</span>
<span style="color: #4f76ac;">function</span> myFunc<span style="color: #1e7c70;">()</span>
<span style="color: #1e7c70;">{</span>
	<span style="color: #4f76ac;">var</span> piloupe <span style="color: #1e7c70;">=</span> <span style="color: #9b5f9b;">true</span>
	<span style="color: #4f76ac;">while</span> <span style="color: #1e7c70;">(</span>piloupe<span style="color: #1e7c70;">)</span>
	<span style="color: #1e7c70;">{</span>
		<span style="color: #4f76ac;">if</span> <span style="color: #1e7c70;">(</span>piloupe<span style="color: #1e7c70;">)</span>
		<span style="color: #1e7c70;">{</span>
			alert<span style="color: #1e7c70;">(</span><span style="color: #823125;">'Hello Nested Regex'</span><span style="color: #1e7c70;">);</span>
			piloupe <span style="color: #1e7c70;">=</span> <span style="color: #9b5f9b;">false</span><span style="color: #1e7c70;">;</span>
		<span style="color: #1e7c70;">}</span>
	<span style="color: #1e7c70;">}</span>
<span style="color: #1e7c70;">}}</span>
exampleChars<span style="color: #1e7c70;">*&amp;^%(((!</span>&pound;<span style="color: #1e7c70;">)!)</span>_<span style="color: #1e7c70;">*</span>$<span style="color: #1e7c70;">))</span></pre>
<p class="MsoNormal" style="background: white; line-height: normal; margin-bottom: 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">&nbsp;</p>
<p class="MsoNormal"><strong>&gt; We want the output string to <span class="GramE">be :</span></strong></p>
<pre style="background: white; color: black; font-family: Consolas; font-size: 10pt;"><span style="color: #4f76ac;">function</span> myFunc<span style="color: #1e7c70;">()</span>
<span style="color: #1e7c70;">{</span>
	<span style="color: #4f76ac;">var</span> piloupe <span style="color: #1e7c70;">=</span> <span style="color: #9b5f9b;">true</span>
	<span style="color: #4f76ac;">while</span> <span style="color: #1e7c70;">(</span>piloupe<span style="color: #1e7c70;">)</span>
	<span style="color: #1e7c70;">{</span>
		<span style="color: #4f76ac;">if</span> <span style="color: #1e7c70;">(</span>piloupe<span style="color: #1e7c70;">)</span>
		<span style="color: #1e7c70;">{</span>
			alert<span style="color: #1e7c70;">(</span><span style="color: #823125;">'Hello Nested Regex'</span><span style="color: #1e7c70;">);</span>
			piloupe <span style="color: #1e7c70;">=</span> <span style="color: #9b5f9b;">false</span><span style="color: #1e7c70;">;</span>
		<span style="color: #1e7c70;">}</span>
	<span style="color: #1e7c70;">}</span>
<span style="color: #1e7c70;">}</span></pre>
<p class="MsoNormal">&nbsp;</p>
<h1 class="WordSection1">The Regex!</h1>
<p class="MsoNormal"><span style="text-decoration: underline;"><strong>1. The identification of the first line is a classic <span class="GramE">Regex</span></strong></span></p>
<p class="MsoNormal"><span style="mso-tab-count: 1;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><strong style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;">function</span></strong></span><strong style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;"> <span class="SpellE">myFunc</span>\(\)\s*</span></strong></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><span style="text-decoration: underline;"><strong>2. Identify the code inside the function</strong></span></p>
<p class="MsoNormal"><span style="text-decoration: underline;"><span style="font-size: medium;">Basic example</span></span> without nested braces:</p>
<div class="WordSection1">
<pre style="background: white; color: black; font-family: Consolas; font-size: 10pt;"><span style="color: #4f76ac;">function</span> myFunc<span style="color: #1e7c70;">()</span>
<span style="color: #1e7c70;">{</span>
	<span style="color: #4f76ac;">var</span> piloupe <span style="color: #1e7c70;">=</span> <span style="color: #9b5f9b;">true</span><span style="color: #1e7c70;">;</span>
<span style="color: #1e7c70;">}</span>
<span style="color: #1e7c70;">}</span></pre>
</div>
<p class="MsoNormal"><span class="GramE"><span style="font-size: medium; text-decoration: underline;">Regex</span> :</span></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><span class="SpellE"><strong style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;">function myFunc</span></strong></span><strong style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;">\(\)\s*</span><span style="color: #c00000;">\{</span><span style="color: #262626; mso-themecolor: text1; mso-themetint: 217; mso-style-textfill-fill-color: #262626; mso-style-textfill-fill-themecolor: text1; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: 'lumm=85000 lumo=15000';">(?</span><span style="color: #4f6228; mso-themecolor: accent3; mso-themeshade: 128; mso-style-textfill-fill-color: #4F6228; mso-style-textfill-fill-themecolor: accent3; mso-style-textfill-fill-alpha: 100.0%;">:<span style="color: #00ff00;">[^{}]</span></span><span style="color: #262626; mso-themecolor: text1; mso-themetint: 217; mso-style-textfill-fill-color: #262626; mso-style-textfill-fill-themecolor: text1; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: 'lumm=85000 lumo=15000';">)</span><span style="color: #c00000;">\}</span></strong></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">The <strong style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;">blue </span></strong>element identifies the beginning of the function.</p>
<p class="MsoNormal">The <strong style="mso-bidi-font-weight: normal;"><span style="color: #c00000;">red </span></strong>elements identify the opening and closing braces.</p>
<p class="MsoNormal">The <strong style="mso-bidi-font-weight: normal;">black </strong>brackets<strong style="mso-bidi-font-weight: normal;"> </strong>create a non-capturing group.</p>
<p class="MsoNormal">The <span style="color: #00ff00;"><strong style="mso-bidi-font-weight: normal;">green </strong></span>identifies the elements inside the braces that are not (nested) braces.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><span style="text-decoration: underline;"><strong>3. Identify Nested braces</strong></span></p>
<p class="MsoNormal">If our function has nested braces we need to use <a href="https://msdn.microsoft.com/en-us/library/bs2twtah.aspx#balancing_group_definition">Balancing Groups</a>:</p>
<p class="MsoNormal"><span style="text-decoration: underline;"><span style="font-size: medium;">Regex</span>:</span></p>
<p class="MsoNormal"><strong style="mso-bidi-font-weight: normal;"></strong>&nbsp;</p>
<p class="MsoNormal"><strong style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;">function myFunc\(\)\s*</span><span style="color: #c00000;">\{</span>(?:<span style="color: #00ff00;">[^{}]</span></strong>|<strong style="mso-bidi-font-weight: normal;"><span style="color: #e46c0a; mso-themecolor: accent6; mso-themeshade: 191; mso-style-textfill-fill-color: #E46C0A; mso-style-textfill-fill-themecolor: accent6; mso-style-textfill-fill-alpha: 100.0%;">(?&lt;counter&gt;\{)</span></strong>|<strong style="mso-bidi-font-weight: normal;"><span style="color: #e46c0a; mso-themecolor: accent6; mso-themeshade: 191; mso-style-textfill-fill-color: #E46C0A; mso-style-textfill-fill-themecolor: accent6; mso-style-textfill-fill-alpha: 100.0%;">(?&lt;-counter&gt;\})</span>)</strong>+<strong style="mso-bidi-font-weight: normal;"><span style="color: #ef3de7;">(?(counter)(?!))</span><span style="color: #c00000;">\}</span></strong></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">The <strong style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;">blue </span></strong>element identifies the beginning of the function.</p>
<p class="MsoNormal">The <strong style="mso-bidi-font-weight: normal;"><span style="color: #c00000;">red </span></strong>elements identify the opening and closing braces.</p>
<p class="MsoNormal">The <strong style="mso-bidi-font-weight: normal;">black </strong>brackets<strong style="mso-bidi-font-weight: normal;"> </strong>create a non-capturing group that will be used as a &ldquo;loop&rdquo;.</p>
<p class="MsoNormal">The <span style="color: #00ff00;"><strong style="mso-bidi-font-weight: normal;">green </strong></span>identifies the elements inside the braces that are not (nested) braces.</p>
<p class="MsoNormal">The <strong style="mso-bidi-font-weight: normal;"><span style="color: #e46c0a; mso-themecolor: accent6; mso-themeshade: 191; mso-style-textfill-fill-color: #E46C0A; mso-style-textfill-fill-themecolor: accent6; mso-style-textfill-fill-alpha: 100.0%;">orange</span></strong> elements identify the opening and closing <span style="text-decoration: underline;">nested</span> braces. When a first opening brace is discovered the counter increases to one. The counter has initially a value of 0. The <strong style="mso-bidi-font-weight: normal;"><span style="color: #4f6228; mso-themecolor: accent3; mso-themeshade: 128; mso-style-textfill-fill-color: #4F6228; mso-style-textfill-fill-themecolor: accent3; mso-style-textfill-fill-alpha: 100.0%;">green</span></strong>identified all the elements before any brace.</p>
<div class="WordSection1">
<ul>
<li>
<div class="MsoNormal" style="text-indent: 0.55pt; margin-left: 35.45pt;">If the character detected after the green is a closing brace the regex analyses the current value of the <em style="mso-bidi-font-style: normal;">counter</em> and leaves the <strong style="mso-bidi-font-weight: normal;">Black</strong> &ldquo;loop&rdquo; if its value is 0. If the current value of the <em style="mso-bidi-font-style: normal;">counter</em> is not 0 it decrements the value of the <em style="mso-bidi-font-style: normal;">counter</em> by one (<strong style="mso-bidi-font-weight: normal;"><span style="color: #e46c0a; mso-themecolor: accent6; mso-themeshade: 191; mso-style-textfill-fill-color: #E46C0A; mso-style-textfill-fill-themecolor: accent6; mso-style-textfill-fill-alpha: 100.0%;">(<span class="GramE">?&lt;</span>-counter&gt;\})</span></strong>).</div>
</li>
</ul>
</div>
<p class="MsoNormal" style="text-indent: 0.55pt; margin-left: 35.45pt;">&nbsp;</p>
<ul>
<li>
<div class="MsoNormal" style="text-indent: 0.55pt; margin-left: 35.45pt;">If the character detected after the green is an opening brace it increments the value of the <em style="mso-bidi-font-style: normal;">counter</em> by one (<strong style="mso-bidi-font-weight: normal;"><span style="color: #e46c0a; mso-themecolor: accent6; mso-themeshade: 191; mso-style-textfill-fill-color: #E46C0A; mso-style-textfill-fill-themecolor: accent6; mso-style-textfill-fill-alpha: 100.0%;">(<span class="GramE">?&lt;</span>counter&gt;\{)</span></strong>).</div>
</li>
</ul>
<p class="MsoNormal" style="text-indent: 0.55pt; margin-left: 35.45pt;">&nbsp;</p>
<p class="MsoNormal">The <strong style="mso-bidi-font-weight: normal;"><span style="color: #ef3de7;">pink</span></strong> elements indicates that if the current value of the counter is different from 0 (meaning that there is less closing brackets than opening brackets) the regex is invalid.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">Hope you looped the Regex.</p>
<p class="MsoNormal">Linvi</p>]]></content:encoded>
    </item>
    <item>
      <title>Insert a WebBrowser in a Word Document! Or how to insert a WPF/ Winform Custom UserControl in a Word Document</title>
      <link>https://docs.microsoft.com/archive/blogs/timart/insert-a-webbrowser-in-a-word-document-or-how-to-insert-a-wpf-winform-custom-usercontrol-in-a-word-document</link>
      <pubDate>Mon, 15 Apr 2013 02:34:00 GMT</pubDate>
      <dc:creator><![CDATA[linvỉ]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/timart/2013/04/15/insert-a-webbrowser-in-a-word-document-or-how-to-insert-a-wpf-winform-custom-usercontrol-in-a-word-document/</guid>
      <description><![CDATA[&nbsp;This post provides an example on how to insert custom control inside a Word Document using...]]></description>
      <content:encoded><![CDATA[<p><span style="font-family: Calibri; font-size: small;">&nbsp;</span><span style="font-size: small;"><span style="font-family: Calibri;">This post provides an example on how to insert custom control inside a Word Document using VSTO. You might for example insert controls as button or a whole user interface inside your document.</span></span></p>
<p><span style="font-size: small;"><span style="font-family: Calibri;">These controls might either be Winform or WPF control. </span></span><span style="font-size: small;"><span style="font-family: Calibri;">VSTO allows developers to insert Winform controls inside their document.</span></span></p>
<h1><span style="font-size: medium;"><span style="color: #4f81bd;"><span style="font-family: Cambria;">Create the project</span></span></span></h1>
<p><span style="font-size: small;"><span style="font-family: Calibri;">Create a new project Word 2010 project</span></span></p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/2376.Step1_CreateProject.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/2376.Step1_5F00_CreateProject.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/2376.Step1_CreateProject.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/2376.Step1_5F00_CreateProject.png" alt="" width="352" height="172" border="0" /></a></p>
<p><span style="font-size: small;"><span style="font-family: Calibri;">Then select &ldquo;Create a new document&rdquo;.</span></span></p>
<p><span style="font-size: small;"><span style="font-family: Calibri;">When the project finished loading, click F7 to open the code behind. </span></span></p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/7215.Step2_StartingPoint.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/7215.Step2_5F00_StartingPoint.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/7215.Step2_StartingPoint.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/7215.Step2_5F00_StartingPoint.png" alt="" width="445" height="344" border="0" /></a></p>
<p>&nbsp;</p>
<h1><span style="font-size: medium;"><span style="color: #4f81bd;"><span style="font-family: Cambria;">Create the WPF UserControl</span></span></span></h1>
<p><span style="font-size: small;"><span style="font-family: Calibri;">Select the current project and &ldquo;Add an Item&rdquo;, select &ldquo;Visual C# Items &gt; WPF &gt;<strong> Use Control (WPF)</strong>&rdquo;.</span></span></p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/8836.Step3_InsertWPFUserControl.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/8836.Step3_5F00_InsertWPFUserControl.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/8836.Step3_InsertWPFUserControl.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/8836.Step3_5F00_InsertWPFUserControl.png" alt="" width="296" height="227" border="0" /></a></p>
<p><span style="font-size: small;"><span style="font-family: Calibri;">You can add any component that you feel useful for your document interface.</span></span></p>
<p><span style="font-size: small;"><span style="font-family: Calibri;">I personally decided to implement a simple WebBrowser.</span></span></p>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">UserControl</span><span style="color: red;">&nbsp;x</span><span style="color: blue;">:</span><span style="color: red;">Class</span><span style="color: blue;">=</span><span style="color: blue;">"WordCustomControl.WPFUserControl"</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: red;">&nbsp;xmlns</span><span style="color: blue;">=</span><span style="color: blue;">"https://schemas.microsoft.com/winfx/2006/xaml/presentation"</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: red;">&nbsp;xmlns</span><span style="color: blue;">:</span><span style="color: red;">x</span><span style="color: blue;">=</span><span style="color: blue;">"https://schemas.microsoft.com/winfx/2006/xaml"</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: red;">&nbsp;xmlns</span><span style="color: blue;">:</span><span style="color: red;">mc</span><span style="color: blue;">=</span><span style="color: blue;">"https://schemas.openxmlformats.org/markup-compatibility/2006"</span>&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: red;">&nbsp;xmlns</span><span style="color: blue;">:</span><span style="color: red;">d</span><span style="color: blue;">=</span><span style="color: blue;">"https://schemas.microsoft.com/expression/blend/2008"</span>&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: red;">&nbsp;mc</span><span style="color: blue;">:</span><span style="color: red;">Ignorable</span><span style="color: blue;">=</span><span style="color: blue;">"d"</span>&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: red;">&nbsp;d</span><span style="color: blue;">:</span><span style="color: red;">DesignHeight</span><span style="color: blue;">=</span><span style="color: blue;">"300"</span><span style="color: red;">&nbsp;d</span><span style="color: blue;">:</span><span style="color: red;">DesignWidth</span><span style="color: blue;">=</span><span style="color: blue;">"300"</span><span style="color: blue;">&gt;</span>
<span style="color: #a31515;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;</span><span style="color: #a31515;">Grid</span><span style="color: blue;">&gt;</span>
<span style="color: #a31515;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;</span><span style="color: #a31515;">WebBrowser</span><span style="color: red;">&nbsp;Name</span><span style="color: blue;">=</span><span style="color: blue;">"MyWebBrowser"</span><span style="color: blue;">&nbsp;/&gt;</span>
<span style="color: #a31515;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;/</span><span style="color: #a31515;">Grid</span><span style="color: blue;">&gt;</span>
<span style="color: blue;">&lt;/</span><span style="color: #a31515;">UserControl</span><span style="color: blue;">&gt;</span></pre>
<p><span style="font-family: Calibri; font-size: small;">&nbsp;</span></p>
<p><span style="font-size: small;"><span style="font-family: Calibri;">Here is the code behind:</span></span></p>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;"> public</span>&nbsp;<span style="color: blue;">partial</span>&nbsp;<span style="color: blue;">class</span>&nbsp;<span style="color: #2b91af;">WinformUserControl</span>&nbsp;:&nbsp;<span style="color: #2b91af;">UserControl</span>
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span>&nbsp;WinformUserControl()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InitializeComponent();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elementHost1.Child&nbsp;=&nbsp;<span style="color: blue;">new</span>&nbsp;<span style="color: #2b91af;">WPFUserControl</span>();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}</pre>
<p><span style="font-family: Calibri; font-size: small;">&nbsp;</span></p>
<h1><span style="font-size: medium;"><span style="color: #4f81bd;"><span style="font-family: Cambria;">Create the Winform UserControl</span></span></span></h1>
<p><span style="font-size: small;"><span style="font-family: Calibri;">Now create a Winform User Control.</span></span></p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/3125.Step4_InsertWinformUserControl.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/3125.Step4_5F00_InsertWinformUserControl.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/3125.Step4_InsertWinformUserControl.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/3125.Step4_5F00_InsertWinformUserControl.png" alt="" width="418" height="98" border="0" /></a></p>
<p><span style="font-size: small;"><span style="font-family: Calibri;">Use your toolbox to insert an ElementHost and Click &ldquo;Dock to parent Container&rdquo;.</span></span></p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/7851.Step5_ElementHost.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/7851.Step5_5F00_ElementHost.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/7851.Step5_ElementHost.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/7851.Step5_5F00_ElementHost.png" alt="" width="474" height="77" border="0" /></a></p>
<p><span style="font-size: small;"><span style="font-family: Calibri;">In your Winform User Control code behind specify that you want the ElementHost to have the WPFUserControl as a child.</span></span></p>
<pre><span style="font-size: x-small;">elementHost1.Child&nbsp;=&nbsp;new&nbsp;WPFUserControl();</span></pre>
<p><span style="font-family: Calibri; font-size: small;">&nbsp;</span></p>
<h1><span style="font-size: medium;"><span style="color: #4f81bd;"><span style="font-family: Cambria;">Insert in the Word Document</span></span></span></h1>
<p><span style="font-size: small;"><span style="font-family: Calibri;">Going back to word code behind (ThisDocument.cs), we now will add some code to insert our control.</span></span></p>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;"> private</span>&nbsp;<span style="color: blue;">void</span>&nbsp;ThisDocument_Startup(<span style="color: blue;">object</span>&nbsp;sender,&nbsp;System.<span style="color: #2b91af;">EventArgs</span>&nbsp;e)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Word.<span style="color: #2b91af;">Paragraph</span>&nbsp;paragraph&nbsp;=&nbsp;<span style="color: blue;">this</span>.Paragraphs.Add();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #2b91af;">WinformUserControl</span>&nbsp;control&nbsp;=&nbsp;<span style="color: blue;">new</span>&nbsp;<span style="color: #2b91af;">WinformUserControl</span>();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Word.<span style="color: #2b91af;">Range</span>&nbsp;range&nbsp;=&nbsp;paragraph.Range;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">float</span>&nbsp;width&nbsp;=&nbsp;450;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">float</span>&nbsp;height&nbsp;=&nbsp;300;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">string</span>&nbsp;objectID&nbsp;=&nbsp;<span style="color: #a31515;">"Winform_UserControl_1"</span>;
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">this</span>.Controls.AddControl(control,&nbsp;range,&nbsp;width,&nbsp;height,&nbsp;objectID);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</pre>
<p><span style="font-family: Calibri; font-size: small;">&nbsp;</span></p>
<p><span style="font-size: small;"><span style="font-family: Calibri;">We now have a WebBrowser inside our word document!</span></span></p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/8154.Step6_FinalResult.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/8154.Step6_5F00_FinalResult.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/8154.Step6_FinalResult.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/8154.Step6_5F00_FinalResult.png" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>Enjoy,</p>
<p>Linvi</p>]]></content:encoded>
    </item>
    <item>
      <title>MSCOMCTL.OCX won’t register</title>
      <link>https://docs.microsoft.com/archive/blogs/timart/mscomctl-ocx-wont-register</link>
      <pubDate>Tue, 09 Apr 2013 02:14:00 GMT</pubDate>
      <dc:creator><![CDATA[linvỉ]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/timart/2013/04/09/mscomctl-ocx-wont-register/</guid>
      <description><![CDATA[I have been facing an issue with the Visual Basic component MSCOMCTL.OCX which I was not able to...]]></description>
      <content:encoded><![CDATA[<p><span style="font-size: 12px;">I have been facing an issue with the Visual Basic component MSCOMCTL.OCX which I was not able to register (Windows 7 - 64bits).</span></p>
<p>I found multiple answers on the internet as:</p>
<ul>
<li>Move the object in a different folder
<ul>
<li>C:\Windows\system</li>
<li>C:\Windows\system32</li>
<li>C:\Windows\SysWOW64</li>
</ul>
</li>
<li>Update the registry</li>
<li>Reinstall VB6&hellip;</li>
</ul>
<p>While trying to use the classic regsvr32 and modifying my registry I found that Internet Explorer 10 might cause some&nbsp;compatibility&nbsp;issues with this component.</p>
<p><strong>Uninstalling Internet Explorer 10 instantly solved the issue.</strong></p>
<p>So please check the version of your internet explorer if you have this issue :)</p>
<p>Linvi</p>]]></content:encoded>
    </item>
    <item>
      <title>Netsh wlan start hostednetwork, The hosted network couldn't be started.</title>
      <link>https://docs.microsoft.com/archive/blogs/timart/netsh-wlan-start-hostednetwork-the-hosted-network-couldnt-be-started</link>
      <pubDate>Sat, 26 Jan 2013 18:26:00 GMT</pubDate>
      <dc:creator><![CDATA[linvỉ]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/timart/2013/01/26/netsh-wlan-start-hostednetwork-the-hosted-network-couldnt-be-started/</guid>
      <description><![CDATA[While trying to share my wifi connection, the error "The hosted network couldn't be started. The...]]></description>
      <content:encoded><![CDATA[<pre><span style="font-size: medium;">While trying to share my wifi connection, the error "The hosted network couldn't be started. The group or resource is not in the correct state to perform the requested operation." happened and I wanted to share how to solve this issue.</span></pre>
<pre><span style="font-size: medium;">The problem comes from the adapter that can be in "sleep mode".</span></pre>
<pre><span style="font-size: medium;">As explained in the KB (<a title="https://support.microsoft.com/kb/2625519" href="https://support.microsoft.com/kb/2625519">https://support.microsoft.com/kb/2625519</a>), follow this instructions : </span></pre>
<ol>
<li><span style="font-size: medium;">Click on the Start button and select Control Panel.</span></li>
<li><span style="font-size: medium;">Select System and Security.</span></li>
<li><span style="font-size: medium;">Select Device Manager under System.</span></li>
<li><span style="font-size: medium;">Select and expand the Network adapters from the list of devices.</span></li>
<li><span style="font-size: medium;">Find the wireless network adapter and right-click on&nbsp;it and select Properties.</span><br /><span style="font-size: medium;">&gt; <span style="color: #0000ff;">If you cannot find your adapter in the device manager you might need to restart your computer.<br /><span style="color: #000000;">&gt; <span style="color: #0000ff;">The 2 next steps are not really required, what you need to do now is to enable your device</span></span></span></span></li>
<li><span style="font-size: medium;">Select the Power Management tab.</span></li>
<li><span style="font-size: medium;">Under the Power Management tab, make sure the following option is checked (enabled): &ldquo;<em>Allow the computer to turn off this device to save power</em>".</span></li>
</ol>
<pre><span style="white-space: normal; font-size: medium;">You should now be able to restart your hosted network using the classical wlan command.</span></pre>
<pre><span style="font-size: medium;"><span style="white-space: normal;">"</span>PS C:\Windows\system32&gt; netsh wlan start hostednetwork</span></pre>
<pre><span style="font-size: medium;">The hosted network started."</span></pre>
<pre><span style="font-size: medium;">Hope this helps.</span></pre>
<pre><span style="font-size: medium;">Linvi</span></pre>]]></content:encoded>
    </item>
    <item>
      <title>SQL server 2012  Install/Update Failure - 84B20001</title>
      <link>https://docs.microsoft.com/archive/blogs/timart/sql-server-2012-installupdate-failure-84b20001</link>
      <pubDate>Fri, 19 Oct 2012 12:46:00 GMT</pubDate>
      <dc:creator><![CDATA[linvỉ]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/timart/2012/10/19/sql-server-2012-installupdate-failure-84b20001/</guid>
      <description><![CDATA[When trying to update SQL Server 2012 with the patch KB2716442 (Windows 8) I was not able to solve...]]></description>
      <content:encoded><![CDATA[<p>When trying to update SQL Server 2012 with the patch KB2716442 (Windows 8) I was not able to solve the issue 84B20001.</p>
<p>Going on&nbsp;<a href="https://support.microsoft.com/kb/2716442">https://support.microsoft.com/kb/2716442</a>&nbsp;I was not able to solve the issue neither so I wanted to share how I solved this issue.</p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/1106.SQLServer2012_2716442.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/1106.SQLServer2012_5F00_2716442.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/1106.SQLServer2012_2716442.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/1106.SQLServer2012_5F00_2716442.png" alt="" width="400" /></a></p>
<p>&nbsp;</p>
<p>To solve the issue type "Regedit" in your start menu.</p>
<p><em><strong>UPDATE 01/26/2013 :&nbsp;</strong></em></p>
<p><em><strong>Some comments describe that depending on your SQL version you might want to change other keys. For example setting the registry key "HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\110\ConfigurationState" to 1 helps completing some installations.</strong></em></p>
<p><em><strong>Thank you for sharing your experiences.</strong></em></p>
<p><em><strong><br /></strong></em></p>
<div class="post-author">Goto :&nbsp;HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\100\ConfigurationState&nbsp;</div>
<p>You might have some Keys with a value of 3. Change all the keys so that they have a value of 1.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/1537.SQLServer2012_Regedit.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/1537.SQLServer2012_5F00_Regedit.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/1537.SQLServer2012_Regedit.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/1537.SQLServer2012_5F00_Regedit.png" alt="" width="400" /></a></p>
<p>This operation works for SQL Server 2008, SQL server 2008 R2 by using the node 100 in the regedit and SQL server 2012 uses 110.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/3716.SQLServer2012_Success.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/3716.SQLServer2012_5F00_Success.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/3716.SQLServer2012_Success.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/3716.SQLServer2012_5F00_Success.png" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Hope this will help you.</p>
<p>Linvi</p>]]></content:encoded>
    </item>
    <item>
      <title>TypeScript project in Visual Studio 2012</title>
      <link>https://docs.microsoft.com/archive/blogs/timart/typescript-project-in-visual-studio-2012</link>
      <pubDate>Tue, 02 Oct 2012 08:49:00 GMT</pubDate>
      <dc:creator><![CDATA[linvỉ]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/timart/2012/10/02/typescript-project-in-visual-studio-2012/</guid>
      <description><![CDATA[Introduction
Reading some forums, I have seen some people having troubles creating a new TypeScript...]]></description>
      <content:encoded><![CDATA[<h2 style="color: #4f81bd;">Introduction</h2>
<p>Reading some forums, I have seen some people having troubles creating a new TypeScript project in Visual Studio 2012.</p>
<p>This is a quick tutorial to demonstrate the creation of a default project.</p>
<p>&nbsp;</p>
<h2 style="color: #4f81bd;">Hello TypeScript</h2>
<p>Go to the Microsoft <a href="https://www.microsoft.com/en-us/download/details.aspx?id=34790">Download page</a> and install the <span style="text-decoration: underline;">Visual Studio 2012</span> plugin. Some people do have some trouble to find the new project directly after installation, in that case restart your session.</p>
<p>If you still do not have the plugin installed, please go to "<strong>C:\Program Files (x86)\Microsoft SDKs\TypeScript\0.8.0.0</strong>"</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/6052.0.%20vsix.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/6052.0.-vsix.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/6052.0.%20vsix.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/6052.0.-vsix.png" border="0" alt="" /></a></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/6052.0.%20vsix.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/6052.0.-vsix.png"></a>Install the <strong>TypeScriptLanguageService.vsix</strong> to add the plugin to Visual Studio.</p>
<p></p>
<p>The TypeScript application project can be found under Visual C# and is called HTML Application with TypeScript.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/8741.1.%20VS2012-New%20Project.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/8741.1.-VS2012_2D00_New-Project.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/8741.1.%20VS2012-New%20Project.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/8741.1.-VS2012_2D00_New-Project.png" border="0" alt="" /></a></p>
<p align="left">&nbsp;</p>
<p>After the project has been created your new project should look like this.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/7485.2.%20Default%20Project%20Files.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/7485.2.-Default-Project-Files.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/7485.2.%20Default%20Project%20Files.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/7485.2.-Default-Project-Files.png" width="300" /></a></p>
<p></p>
<p>Clicking F5 will tell you that you need a Web.Config file to enable debugging.</p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/5531.3.%20Debugging.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/5531.3.-Debugging.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/5531.3.%20Debugging.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/5531.3.-Debugging.png" width="400" /></a></p>
<p></p>
<p>Click Ok, the project should start in your browser and you are good to go!</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/0702.4.%20First%20Screen.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/0702.4.-First-Screen.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/0702.4.%20First%20Screen.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/0702.4.-First-Screen.png" width="400" /></a></p>
<h2 style="color: #4f81bd;">What&rsquo;s next?</h2>
<p>I will try to make some tutorial concerning this new language and providing some examples combining Node.Js and TypeScript.</p>
<p>Until then enjoy developing :)</p>]]></content:encoded>
    </item>
    <item>
      <title>Bulk Copy - Use BCP from SQL to concat databases</title>
      <link>https://docs.microsoft.com/archive/blogs/timart/bulk-copy-use-bcp-from-sql-to-concat-databases</link>
      <pubDate>Thu, 30 Aug 2012 18:44:00 GMT</pubDate>
      <dc:creator><![CDATA[linvỉ]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/timart/2012/08/30/bulk-copy-use-bcp-from-sql-to-concat-databases/</guid>
      <description><![CDATA[Introduction
This post&rsquo;s goal is to introduce you to Bulk Copy. We&rsquo;ll create a SQL...]]></description>
      <content:encoded><![CDATA[<h2 style="color: #4f81bd;">Introduction</h2>
<p>This post&rsquo;s goal is to introduce you to Bulk Copy. We&rsquo;ll create a SQL query which is going to concatenate several attached databases and extract the data to an output csv file.</p>
<p>The first goal is to demonstrate how to use Bulk Copy as well as solving an issue that I sometime encountered for some customers, meaning, converting several databases into a single one and extract it as CSV.</p>
<p>To fully understand the post, you&rsquo;ll need some knowledge about SQL and how to make queries.</p>
<p>You can download the final SQL script <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/34/52/11/BCP%20-%20Bulk%20Copy.sql" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-34-52-11/BCP-_2D00_-Bulk-Copy.sql" title="here">here</a>.</p>
<h3 style="color: #4f81bd;">Bulk Copy</h3>
<p>Bulk Copy also known as BCP is a command line tool installed on your server during SQL installation and is located here:</p>
<p>&nbsp; &nbsp;&nbsp;<span style="white-space: pre;" class="Apple-tab-span"> </span><span style="text-decoration: underline;"><span style="color: #0000ff; text-decoration: underline;">C:\Program Files\Microsoft SQL Server\100\Tools\Binn\bcp.exe</span></span></p>
<p>BCP is a tool which allows copying large amounts of data from one location to another. You may use this tool from a .NET application, using the class <span style="color: #4f81bd;">SqlBulkCopy</span>, Powershell or directly in a SQL query via <span style="color: #de0e01; font-family: 'times new roman', times;">xp_cmdshell</span>. We will see that bcp allows us to extract data directly from a table or through a SQL <span style="color: #3366ff;"><strong>SELECT</strong></span> query.</p>
<p>You coud find more details concerning bcp at <a href="https://msdn.microsoft.com/en-us/library/ms162802.aspx">https://msdn.microsoft.com/en-us/library/ms162802.aspx</a>.</p>
<h2 style="color: #4f81bd;">Developing the script</h2>
<h4>Context</h4>
<p>Our company has 2 databases saved in *.mdf files, each containing 2 tables <i>Customer</i> and <i>Order</i>. An <i>Order</i> is linked to a <i>Customer</i> through its <i>CustomerID</i> field (1.* relationship).&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/1452.bcp_databases.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/1452.bcp_5F00_databases.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/1452.bcp_databases.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/1452.bcp_5F00_databases.png" border="0" alt="" style="width: 350px;" /></a></p>
<h3 style="color: #4f81bd;">Setting the database configuration</h3>
<p>To be able to use BCP, we need to execute a command on the server. By default SQL server does not allow this.</p>
<p>To enable this feature just use the following query.</p>
<table border="0" style="background-color: #e1eaff; border-width: 0px; border-color: #c9c8c4; border-style: solid;" lang="SQL">
<tbody>
<tr>
<td>
<pre class="scroll"><code class="mysql">EXECUTE sp_configure 'show advanced options', 1;<br />RECONFIGURE WITH OVERRIDE;<br /><br /></code></pre>
<pre class="scroll"><code class="mysql">EXECUTE sp_configure 'xp_cmdshell', '1';<br />RECONFIGURE WITH OVERRIDE;<br /><br /></code></pre>
<pre class="scroll"><code class="mysql">EXECUTE sp_configure 'show advanced options', 0;<br />RECONFIGURE WITH OVERRIDE; </code></pre>
</td>
</tr>
</tbody>
</table>
<p>If you don't you'll receive the following error message :</p>
<pre><span style="color: #ff0000;"><em>Msg 15281, Level 16, State 1, Procedure xp_cmdshell, Line 1</em></span><br /><span style="color: #ff0000;"><em>SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security configuration for this server.&nbsp;</em></span><br /><span style="color: #ff0000;"><em>A system administrator can enable the use of 'xp_cmdshell' by using sp_configure. For more information about enabling 'xp_cmdshell', search for 'xp_cmdshell' in SQL Server Books Online.</em></span></pre>
<h3 style="color: #4f81bd;">Testing Bulk Copy</h3>
<p>In a first time we are going to test bcp and just export the table customer to as csv file.</p>
<p>For test purposes just insert row into bcp_demo_1 and bcp_demo_2 :&nbsp;</p>
<table border="0" style="background-color: #e1eaff; border-width: 0px; border-color: #c9c8c4; border-style: solid;" lang="SQL">
<tbody>
<tr>
<td>
<p><span style="color: #0000ff;">INSERT</span> <span style="color: #0000ff;">INTO</span> <span style="color: #008000;">[bcp_demo_1].[dbo].Customer (FirstName, LastName, Address)</span> <span style="color: #0000ff;">VALUES</span> (<span style="color: #ff0000;">'linvi'</span>, <span style="color: #ff0000;">'me'</span>,<span style="color: #ff0000;"> 'landinvi'</span>);</p>
<p><span style="color: #0000ff;">INSERT</span> <span style="color: #0000ff;">INTO</span> <span style="color: #008000;">[bcp_demo_2].[dbo].Customer (FirstName, LastName, Address)</span> <span style="color: #0000ff;">VALUES</span> (<span style="color: #ff0000;">'linvi2'</span>, <span style="color: #ff0000;">'me2'</span>,<span style="color: #ff0000;"> 'landinvi2'</span>);</p>
</td>
</tr>
</tbody>
</table>
<p>Now we can take a look to the copy:</p>
<table border="0" style="background-color: #e1eaff; border: 0px solid #c9c8c4; width: 500px;" lang="SQL">
<tbody>
<tr>
<td>
<p><span style="color: #0000ff;">DECLARE</span> @folder&nbsp;<span style="color: #0000ff;">varchar</span>(512);<br /> <span style="color: #0000ff;">SET</span> @folder = <span style="color: #ff0000;">'C:\temp\'</span>;</p>
<p><span style="color: #0000ff;">DECLARE</span><span>&nbsp;@query&nbsp;</span><span style="color: #0000ff;">varchar</span><span>(512);<br /></span><span style="color: #0000ff;">SET</span> @query = <span style="color: #ff0000;">'bcp "SELECT * FROM [bcp_demo_1].[dbo].Customer" queryout&nbsp;'</span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + @folder<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + <span style="color: #ff0000;">'result.csv -c <span>-t,&nbsp;</span>-T -S '</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + (<span style="color: #0000ff;">select</span> srvname <span style="color: #0000ff;">from</span> <span style="color: #008000;">sys.sysservers</span>);<br /><br /> <span style="color: #0000ff;">EXEC</span> <span style="color: #0000ff;">master</span>..<span style="color: #980000;">xp_cmdshell</span> @query;</p>
</td>
</tr>
</tbody>
</table>
<p style="color: #4f81bd;"></p>
<p style="color: #4f81bd;"><span style="color: #000000;">After executing this query, some information will be sent to you. They gave you some log information concerning BCP execution.</span></p>
<p style="color: #4f81bd;"><span style="color: #000000;">As you can see, BCP can take some parameters, for defining how the data are going to be parsed, or how it is going to render them in the external source.</span></p>
<p style="color: #4f81bd;"><span style="color: #000000;">-c : Allows you to specify a character format or without argument the default one<br />-t &nbsp;: Allows you to specify a special character for your separation in the csv file (here comma ",")<br />-T : Means that I connect to a trusted connection using integrated security.<br />-S : Allows me to specify the name of the database that I will connect on&nbsp;</span></p>
<p style="color: #4f81bd;"><span style="color: #000000;">For a complete list of the parameters please visit : <a href="https://msdn.microsoft.com/en-us/library/ms162802.aspx">https://msdn.microsoft.com/en-us/library/ms162802.aspx</a>&nbsp;</span></p>
<p style="color: #4f81bd;"></p>
<p style="color: #4f81bd;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/2022.BCP_Default_Display.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/2022.BCP_5F00_Default_5F00_Display.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/2022.BCP_Default_Display.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/2022.BCP_5F00_Default_5F00_Display.png" width="350" /></a></p>
<p>To remove this output just use&nbsp;NO_OUTPUT as a parameter of <span style="color: #ff0000;">xp_cmdshell&nbsp;</span>:</p>
<table border="0" style="background-color: #e1eaff; border-width: 0px; border-color: #c9c8c4; border-style: solid;" lang="SQL">
<tbody>
<tr>
<td><span><span style="color: #0000ff;">EXEC</span> <span style="color: #0000ff;">master</span>..<span style="color: #980000;">xp_cmdshell</span> @query, <span style="color: #008000;">NO_OUTPUT</span>;</span></td>
</tr>
</tbody>
</table>
<p></p>
<h3 style="color: #4f81bd;">Detect all existing Tables to copy</h3>
<p>Now we will create 2 tables named : bcp_demo_1 and bcp_demo_2.</p>
<div><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/3731.SQL_Server_NewDB.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/3731.SQL_5F00_Server_5F00_NewDB.png"> <img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/3731.SQL_Server_NewDB.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/3731.SQL_5F00_Server_5F00_NewDB.png" width="350" /> </a> <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/0247.SQL_Server_NewDB_2.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/0247.SQL_5F00_Server_5F00_NewDB_5F00_2.png"> <img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/0247.SQL_Server_NewDB_2.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/0247.SQL_5F00_Server_5F00_NewDB_5F00_2.png" border="0" alt="" /> </a></div>
<p><br />Now that we have the 2 databases, we can simply retrieving them thanks to a Regex, that will allow you to get all the tables you require to be concatenated.</p>
<table border="0" style="background-color: #e1eaff; border-width: 0px; border-color: #c9c8c4; border-style: solid;" lang="SQL">
<tbody>
<tr>
<td>
<p><span style="color: #0000ff;">DECLARE</span> <span style="color: #008000;">@databaseNameRegex&nbsp;varchar</span>(100);<br /><span style="color: #0000ff;">SET</span> <span style="color: #008000;">@databaseNameRegex</span>&nbsp;= '%bcp_demo_%';</p>
<p><span style="color: #0000ff;">DECLARE</span> <span style="color: #008000;">@tables</span>&nbsp;<span style="color: #0000ff;">TABLE </span>(TableNb int, TableName varchar(64))<br /><span style="color: #0000ff;">INSERT</span> &nbsp;<span style="color: #008000;">@tables</span><span color="#0000ff"><br /></span><span style="color: #0000ff;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SELECT</span> <span style="color: #ff00ff;">ROW_NUMBER()</span> <span style="color: #0000ff;">OVER</span> (<span style="color: #0000ff;">ORDER BY</span> Name <span style="color: #0000ff;">ASC</span>) <span style="color: #0000ff;">AS</span> <span>TableNb</span>, Name&nbsp;<span style="color: #0000ff;">FROM</span> <span style="color: #008000;">sys.databases</span>&nbsp;<br /><span style="color: #0000ff;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="Apple-tab-span" style="white-space: pre;"> </span>WHERE</span> <span style="color: #339966;">owner_sid</span> &lt;&gt; 0x01 <span style="color: #0000ff;"> AND</span> Name <span style="color: #0000ff;">LIKE</span> <span style="color: #008000;">@databaseNameRegex</span>;</p>
<div><span style="color: #0000ff;">SELECT</span>&nbsp;* <span style="color: #0000ff;"> FROM</span> &nbsp;<span style="color: #008000;">@tables</span>;</div>
</td>
</tr>
</tbody>
</table>
<p>This script list the databases which name is LIKE&nbsp;<span>'%bcp_demo_%'; and create a temporary TABLE of this databases name to be able to query them later, one by one.</span></p>
<h3 style="color: #4f81bd;">Push all data in one table</h3>
<p>To simplify this script we are first going to push all the data into a temporary table</p>
<table border="0" style="background-color: #e1eaff; border-width: 0px; border-color: #c9c8c4; border-style: solid;" lang="SQL">
<tbody>
<tr>
<td>
<pre><span style="color: #339966;">-- List of tables to concatenate</span></pre>
<p><span style="color: #0000ff;">DECLARE</span> <span style="color: #008000;">@databaseNameRegex&nbsp;varchar</span>(100);<br /><span style="color: #0000ff;">SET</span> <span style="color: #008000;">@databaseNameRegex</span>&nbsp;= '%bcp_demo_%';</p>
<p><span style="color: #0000ff;">DECLARE</span> <span style="color: #008000;">@tables</span>&nbsp;<span style="color: #0000ff;">TABLE </span>(TableNb int, TableName varchar(64))<br /><span style="color: #0000ff;">INSERT</span> &nbsp;<span style="color: #008000;">@tables</span><span color="#0000ff"><br /></span><span style="color: #0000ff;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SELECT</span> <span style="color: #ff00ff;">ROW_NUMBER()</span> OVER (<span style="color: #0000ff;">ORDER BY</span> Name <span style="color: #0000ff;">ASC</span>) <span style="color: #0000ff;">AS</span> <span>TableNb</span>, Name&nbsp;<span style="color: #0000ff;">FROM</span> <span style="color: #008000;">sys.databases</span>&nbsp;<br /><span style="color: #0000ff;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="Apple-tab-span" style="white-space: pre;"> </span>WHERE</span> <span style="color: #339966;">owner_sid</span> &lt;&gt; 0x01 <span style="color: #0000ff;"> AND</span> Name LIKE <span style="color: #008000;">@databaseNameRegex</span>;</p>
<div><span style="color: #0000ff;">SELECT</span>&nbsp;* <span style="color: #0000ff;"> FROM</span> &nbsp;<span style="color: #008000;">@tables</span>;</div>
<pre><br /><span style="color: #339966;">-- Create temporary Table with all infos</span><br /><br /><span style="color: #0000ff;">DECLARE</span> <span style="color: #339966;">@i</span> int;<br /><span style="color: #0000ff;">SET</span> <span style="color: #339966;">@i</span> = 1;<br /><br /><span style="color: #0000ff;">DECLARE</span> <span style="color: #339966;">@tablesCount</span> int;<br /><span style="color: #0000ff;">SET</span> <span style="color: #339966;">@tablesCount</span> = (<span style="color: #0000ff;">SELECT</span> <span style="color: #ff00ff;">COUNT</span>(*) <span style="color: #0000ff;">FROM</span> <span style="color: #339966;">@tables</span>);<br /><br /><span style="color: #0000ff;">IF <span style="color: #ff00ff;">OBJECT_ID</span></span>(<span style="color: #ff0000;">'[tempdb]..[##data]'</span>)<span style="color: #0000ff;"> IS NOT NULL</span><br />	<span style="color: #0000ff;">BEGIN</span><br />		<span style="color: #0000ff;">DROP TABLE</span> [tempdb].[##data];<br />	<span style="color: #0000ff;">END</span> <br /><br /><span style="color: #0000ff;">CREATE TABLE</span> [tempdb].[##data] (<br />	[id]		<span class="Apple-tab-span" style="white-space: pre;"> </span>       [nchar](20)<span class="Apple-tab-span" style="white-space: pre;"> </span> <span style="color: #0000ff;">NOT NULL</span>,<br />	[FirstName] <span class="Apple-tab-span" style="white-space: pre;"> </span> [nchar](10) <span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #0000ff;">NULL</span>,<br />	[LastName]	[nchar](10) <span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #0000ff;">NULL</span>,<br />	[Address]	[nchar](10) <span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #0000ff;">NULL</span><br />);<br /><br /></pre>
<pre><span style="color: #0000ff;">INSERT INTO</span> [tempdb].[##data] (id, FirstName, LastName, Address)  <span style="color: #0000ff;">VALUES</span> ('Id', 'Firstname', 'LastName', 'Address');</pre>
<pre><br /><span style="color: #0000ff;">WHILE</span> (<span style="color: #339966;">@i</span> &lt;= <span style="color: #339966;">@tablesCount</span>)<br />      <span style="color: #0000ff;">BEGIN</span><br />            <span style="color: #0000ff;">DECLARE</span> <span style="color: #339966;">@table</span> varchar(64);<br />            <span style="color: #0000ff;">SET</span> <span style="color: #339966;">@table</span> = (<span style="color: #0000ff;">SELECT TableName FROM</span> <span style="color: #339966;">@tables</span> <span style="color: #0000ff;">WHERE</span> TableNb = <span style="color: #339966;">@i</span>);<br />            <span style="color: #0000ff;">INSERT</span> [tempdb].[##data] <span style="color: #0000ff;">EXEC</span>(<span style="color: #ff0000;">'SELECT * FROM [</span><span style="color: #ff0000;">'</span> + <span style="color: #339966;">@table</span> + <span style="color: #ff0000;">'].dbo.Customer'</span>);<br />            <span style="color: #0000ff;">SET</span> <span style="color: #339966;">@i</span> = <span style="color: #339966;">@i</span> + 1;<br />      <span style="color: #0000ff;">END</span><br /><br /><span style="color: #0000ff;">SELECT</span> * <span style="color: #0000ff;">FROM</span> [tempdb].[##data];</pre>
</td>
</tr>
</tbody>
</table>
<h3 style="color: #4f81bd;">Full script</h3>
<p>Having all the data in one table will now allow us to move all this data thanks to BCP that we previously saw.</p>
<p>Here is the full script.</p>
<table border="0" style="background-color: #e1eaff; border-width: 0px; border-color: #c9c8c4; border-style: solid;" lang="SQL">
<tbody>
<tr>
<td>
<pre><span style="color: #339966;">-- List of tables to concatenate</span></pre>
<p><span style="color: #0000ff;">DECLARE</span> <span style="color: #008000;">@databaseNameRegex&nbsp;varchar</span>(100);<br /><span style="color: #0000ff;">SET</span> <span style="color: #008000;">@databaseNameRegex</span>&nbsp;= '%bcp_demo_%';</p>
<p><span style="color: #0000ff;">DECLARE</span> <span style="color: #008000;">@tables</span>&nbsp;<span style="color: #0000ff;">TABLE </span>(TableNb int, TableName varchar(64))<br /><span style="color: #0000ff;">INSERT</span> &nbsp;<span style="color: #008000;">@tables</span><span color="#0000ff"><br /></span><span style="color: #0000ff;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SELECT</span> <span style="color: #ff00ff;">ROW_NUMBER()</span> OVER (<span style="color: #0000ff;">ORDER BY</span> Name <span style="color: #0000ff;">ASC</span>) <span style="color: #0000ff;">AS</span> <span>TableNb</span>, Name&nbsp;<span style="color: #0000ff;">FROM</span> <span style="color: #008000;">sys.databases</span>&nbsp;<br /><span style="color: #0000ff;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="Apple-tab-span" style="white-space: pre;"> </span>WHERE</span> <span style="color: #339966;">owner_sid</span> &lt;&gt; 0x01 <span style="color: #0000ff;"> AND</span> Name LIKE <span style="color: #008000;">@databaseNameRegex</span>;</p>
<pre><br /><span style="color: #339966;">-- Create temporary Table with all infos</span><br /><br /><span style="color: #0000ff;">DECLARE</span> <span style="color: #339966;">@i</span> int;<br /><span style="color: #0000ff;">SET</span> <span style="color: #339966;">@i</span> = 1;<br /><br /><span style="color: #0000ff;">DECLARE</span> <span style="color: #339966;">@tablesCount</span> int;<br /><span style="color: #0000ff;">SET</span> <span style="color: #339966;">@tablesCount</span> = (<span style="color: #0000ff;">SELECT</span> <span style="color: #ff00ff;">COUNT</span>(*) <span style="color: #0000ff;">FROM</span> <span style="color: #339966;">@tables</span>);<br /><br /><span style="color: #0000ff;">IF <span style="color: #ff00ff;">OBJECT_ID</span></span>(<span style="color: #ff0000;">'[tempdb]..[##data]'</span>)<span style="color: #0000ff;"> IS NOT NULL</span><br />	<span style="color: #0000ff;">BEGIN</span><br />		<span style="color: #0000ff;">DROP TABLE</span> [tempdb].[##data];<br />	<span style="color: #0000ff;">END</span> <br /><br /><span style="color: #0000ff;">CREATE TABLE</span> [tempdb].[##data] (<br />	[id]		<span class="Apple-tab-span" style="white-space: pre;"> </span>       [nchar](20)<span class="Apple-tab-span" style="white-space: pre;"> </span> <span style="color: #0000ff;">NOT NULL</span>,<br />	[FirstName] <span class="Apple-tab-span" style="white-space: pre;"> </span> [nchar](10) <span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #0000ff;">NULL</span>,<br />	[LastName]	[nchar](10) <span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #0000ff;">NULL</span>,<br />	[Address]	[nchar](10) <span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: #0000ff;">NULL</span><br />);<br /><br /></pre>
<pre><span style="color: #0000ff;">INSERT INTO</span> [tempdb].[##data] (id, FirstName, LastName, Address)  <span style="color: #0000ff;">VALUES</span> ('Id', 'Firstname', 'LastName', 'Address');</pre>
<pre><br /><span style="color: #0000ff;">WHILE</span> (<span style="color: #339966;">@i</span> &lt;= <span style="color: #339966;">@tablesCount</span>)<br />      <span style="color: #0000ff;">BEGIN</span><br />            <span style="color: #0000ff;">DECLARE</span> <span style="color: #339966;">@table</span> varchar(64);<br />            <span style="color: #0000ff;">SET</span> <span style="color: #339966;">@table</span> = (<span style="color: #0000ff;">SELECT <span style="color: #000000;">TableName</span> FROM</span> <span style="color: #339966;">@tables</span> <span style="color: #0000ff;">WHERE</span> TableNb = <span style="color: #339966;">@i</span>);<br />            <span style="color: #0000ff;">INSERT</span> [tempdb].[##data] <span style="color: #0000ff;">EXEC</span>(<span style="color: #ff0000;">'SELECT * FROM [</span><span style="color: #ff0000;">'</span> + <span style="color: #339966;">@table</span> + <span style="color: #ff0000;">'].dbo.Customer'</span>);<br />            <span style="color: #0000ff;">SET</span> <span style="color: #339966;">@i</span> = <span style="color: #339966;">@i</span> + 1;<br />      <span style="color: #0000ff;">END</span><br /><br /><span style="color: #0000ff;">SELECT</span> * <span style="color: #0000ff;">FROM</span> [tempdb].[##data];</pre>
<p><span style="color: #0000ff;">DECLARE</span> @folder&nbsp;<span style="color: #0000ff;">varchar</span>(512);<br /> <span style="color: #0000ff;">SET</span> @folder = <span style="color: #ff0000;">'C:\temp\'</span>;</p>
<p><span style="color: #339966;">-- Execute BCP extraction</span></p>
<p><span style="color: #0000ff;">DECLARE</span><span>&nbsp;@query&nbsp;</span><span style="color: #0000ff;">varchar</span><span>(512);<br /></span><span style="color: #0000ff;">SET</span> @query = <span style="color: #ff0000;">'bcp "SELECT * FROM [tempdb].[##data]" queryout&nbsp;'</span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + @folder<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + <span style="color: #ff0000;">'result.csv -c <span>-t,&nbsp;</span>-T -S '</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + (<span style="color: #0000ff;">select</span> srvname <span style="color: #0000ff;">from</span> <span style="color: #008000;">sys.sysservers</span>);<br /><br /> <span style="color: #0000ff;">EXEC</span> <span style="color: #0000ff;">master</span>..<span style="color: #980000;">xp_cmdshell</span> @query, <span style="color: #008000;">NO_OUTPUT</span>;</p>
</td>
</tr>
</tbody>
</table>
<p>And here is the generated file in the C:\temp&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/7713.csv_result.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/7713.csv_5F00_result.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/7713.csv_result.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/7713.csv_5F00_result.png" width="350" /></a></p>
<p>I hope this will be helpful to some of you.</p>
<p>Linvi</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/34/52/11/BCP%20-%20Bulk%20Copy.sql" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-34-52-11/BCP-_2D00_-Bulk-Copy.sql">BCP - Bulk Copy.sql</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Activate Windows 8 RTM Enterprise without slui (DNS name does not exist)</title>
      <link>https://docs.microsoft.com/archive/blogs/timart/activate-windows-8-rtm-enterprise-without-slui-dns-name-does-not-exist</link>
      <pubDate>Tue, 28 Aug 2012 17:50:00 GMT</pubDate>
      <dc:creator><![CDATA[linvỉ]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/timart/2012/08/28/activate-windows-8-rtm-enterprise-without-slui-dns-name-does-not-exist/</guid>
      <description><![CDATA[If like me you have installed Windows 8 Enterprise on your machine, you have certainly noticed that...]]></description>
      <content:encoded><![CDATA[<p>If like me you have installed Windows 8 Enterprise on your machine, you have certainly noticed that you cannot activate Windows because of a DNS error (DNS name does not exist.) if you do not have a KMS server. The error code is 0x8007232B.</p>
<p>To activate Windows Enterprise we will need to change the key of the license.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/4186.Windows8_Not_Activated_SLUI.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/4186.Windows8_5F00_Not_5F00_Activated_5F00_SLUI.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/4186.Windows8_Not_Activated_SLUI.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/4186.Windows8_5F00_Not_5F00_Activated_5F00_SLUI.png" border="0" alt="" /></a></p>
<p>To activate your account. Take your key on your MSDN account.</p>
<p>Open your Powershell as administrator and type the following commands</p>
<p>&gt; slmgr.vbs /ipk YOUR_KEY<br />&gt; slmgr.vbs /ato</p>
<p>A dialog should now inform you that your Windows license has been activated!</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/3580.Windows8_Activated.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/3580.Windows8_5F00_Activated.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/3580.Windows8_Activated.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/3580.Windows8_5F00_Activated.png" border="0" alt="" /></a></p>
<p>Congratulations your Windows should now be registered.</p>]]></content:encoded>
    </item>
    <item>
      <title>Debugging Node.JS</title>
      <link>https://docs.microsoft.com/archive/blogs/timart/debugging-node-js</link>
      <pubDate>Sat, 21 Jul 2012 01:45:00 GMT</pubDate>
      <dc:creator><![CDATA[linvỉ]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/timart/2012/07/21/debugging-node-js/</guid>
      <description><![CDATA[Node.Js is a simple technology to host a webserver.
I wanted to share the steps to enable debugging...]]></description>
      <content:encoded><![CDATA[<p>Node.Js is a simple technology to host a webserver.</p>
<p>I wanted to share the steps to enable debugging on a Windows computer.<br />To debug &nbsp;we will use a very powerful tool : <a href="https://github.com/dannycoates/node-inspector" title="node-inspector">node-inspector</a>. Node inspector is a web-hosted debugger which communicates with your application thanks to WebSocket and will allow you to create breakpoints, update your application in live to improve your capacity to solve the issues you can have.</p>
<ol>
<li><a href="https://nodejs.org/" title="download">Download</a>&nbsp;and install Node.JS.</li>
<li>Type : <span style="font-family: 'courier new', courier;">npm install -g node-inspector</span> to install node-inspector</li>
<li>Open a first Powershell and type : <span style="font-family: 'courier new', courier;">node-inspector<br /></span><span style="font-family: 'courier new', courier;">This will start a server that you can access by default at :&nbsp;</span><a href="https://localhost:8080/debug?port=5858" style="font-family: 'courier new', courier;">https://localhost:8080/debug?port=5858</a></li>
<li>Open a second Powershell, go to your application folder and type :&nbsp;<span style="font-family: 'courier new', courier;">node --debug-brk .\app.js<br />This will start your application in debug mode.</span></li>
<li><span style="font-family: 'courier new', courier;">Go to :&nbsp;<a href="https://localhost:8080/debug?port=5858">https://localhost:8080/debug?port=5858</a>, the application is stopped by default at the start of your app.js application.<br />Use the resume button to launch your application</span></li>
<li><span style="font-family: 'courier new', courier;">Go to :&nbsp;<a href="https://localhost:8080/debug?port=5858">https://localhost:</a><span><a href="https://localhost:8080/debug?port=5858">APP_PORT</a>&nbsp;to access your application</span></span></li>
</ol>
<div>This tool is very powerful and you should be a great help in your projects.</div>
<div></div>
<div><span face="courier new, courier" style="font-family: 'courier new', courier;"><br /></span></div>
<div><span face="courier new, courier" style="font-family: 'courier new', courier;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/3252.Node.js.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/3252.Node.js.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/3252.Node.js.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/1050x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/3252.Node.js.png" border="0" alt="" /></a></span></div>
<div><span face="courier new, courier" style="font-family: 'courier new', courier;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/03/3252.Node.js.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-03/3252.Node.js.png"></a><br /></span></div>]]></content:encoded>
    </item>
  </channel>
</rss>