<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>All things .NET and beyond</title>
    <link>http://www.fluxtah.com/</link>
    <description>Ian (Fluxtah) Warwick's blog</description>
    <language>en-us</language>
    <copyright>Ian Warwick</copyright>
    <lastBuildDate>Sun, 07 Mar 2010 19:18:27 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>fluxtah@hotmail.com</managingEditor>
    <webMaster>fluxtah@hotmail.com</webMaster>
    <item>
      <trackback:ping>http://www.fluxtah.com/Trackback.aspx?guid=a59729ca-4433-4e52-bb27-a0db92281c53</trackback:ping>
      <pingback:server>http://www.fluxtah.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.fluxtah.com/PermaLink,guid,a59729ca-4433-4e52-bb27-a0db92281c53.aspx</pingback:target>
      <dc:creator>Fluxtah</dc:creator>
      <wfw:comment>http://www.fluxtah.com/CommentView,guid,a59729ca-4433-4e52-bb27-a0db92281c53.aspx</wfw:comment>
      <wfw:commentRss>http://www.fluxtah.com/SyndicationService.asmx/GetEntryCommentsRss?guid=a59729ca-4433-4e52-bb27-a0db92281c53</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <pre>
          <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px">$itemid <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> JRequest::getVar(
'Itemid' ); $application <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> JFactory::getApplication();
$menu <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> $application-&gt;getMenu();
$item <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> $menu-&gt;getItem(
$itemid ); <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">return</span> $item-&gt;name;</span>
        </pre>
        <img width="0" height="0" src="http://www.fluxtah.com/aggbug.ashx?id=a59729ca-4433-4e52-bb27-a0db92281c53" />
      </body>
      <title>Get selected menu item name in Joomla</title>
      <guid isPermaLink="false">http://www.fluxtah.com/PermaLink,guid,a59729ca-4433-4e52-bb27-a0db92281c53.aspx</guid>
      <link>http://www.fluxtah.com/2010/03/07/GetSelectedMenuItemNameInJoomla.aspx</link>
      <pubDate>Sun, 07 Mar 2010 19:18:27 GMT</pubDate>
      <description>&lt;pre&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"&gt;$itemid &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; JRequest::getVar(
'Itemid' ); $application &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; JFactory::getApplication();
$menu &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; $application-&amp;gt;getMenu();
$item &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; $menu-&amp;gt;getItem(
$itemid ); &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;return&lt;/span&gt; $item-&amp;gt;name;&lt;/span&gt;&lt;/pre&gt;&lt;img width="0" height="0" src="http://www.fluxtah.com/aggbug.ashx?id=a59729ca-4433-4e52-bb27-a0db92281c53" /&gt;</description>
      <comments>http://www.fluxtah.com/CommentView,guid,a59729ca-4433-4e52-bb27-a0db92281c53.aspx</comments>
      <category>PHP</category>
      <category>Joomla</category>
    </item>
    <item>
      <trackback:ping>http://www.fluxtah.com/Trackback.aspx?guid=73917a6b-9f99-4ca2-94fb-d253359594b4</trackback:ping>
      <pingback:server>http://www.fluxtah.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.fluxtah.com/PermaLink,guid,73917a6b-9f99-4ca2-94fb-d253359594b4.aspx</pingback:target>
      <dc:creator>Fluxtah</dc:creator>
      <wfw:comment>http://www.fluxtah.com/CommentView,guid,73917a6b-9f99-4ca2-94fb-d253359594b4.aspx</wfw:comment>
      <wfw:commentRss>http://www.fluxtah.com/SyndicationService.asmx/GetEntryCommentsRss?guid=73917a6b-9f99-4ca2-94fb-d253359594b4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
First 16 numbers of the fibonacci series
</p>
        <p>
        </p>
        <pre>
          <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px">
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">void</span> Main(){ <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">for</span>(<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">long</span> i=0,
n=0, a <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> 1,
b <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> 0;
i &lt; 16; i++, Console.WriteLine(n), b <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> a,
a <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> n,
n <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> a <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">+</span> b);
}</span>
        </pre>
        <img width="0" height="0" src="http://www.fluxtah.com/aggbug.ashx?id=73917a6b-9f99-4ca2-94fb-d253359594b4" />
      </body>
      <title>Fibonacci in C#</title>
      <guid isPermaLink="false">http://www.fluxtah.com/PermaLink,guid,73917a6b-9f99-4ca2-94fb-d253359594b4.aspx</guid>
      <link>http://www.fluxtah.com/2010/03/01/FibonacciInC.aspx</link>
      <pubDate>Mon, 01 Mar 2010 12:26:57 GMT</pubDate>
      <description>&lt;p&gt;
First 16 numbers of the fibonacci series
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;pre&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;void&lt;/span&gt; Main(){ &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;for&lt;/span&gt;(&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;long&lt;/span&gt; i=0,
n=0, a &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; 1,
b &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; 0;
i &amp;lt; 16; i++, Console.WriteLine(n), b &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; a,
a &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; n,
n &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; a &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;+&lt;/span&gt; b);
}&lt;/span&gt;&lt;/pre&gt;&lt;img width="0" height="0" src="http://www.fluxtah.com/aggbug.ashx?id=73917a6b-9f99-4ca2-94fb-d253359594b4" /&gt;</description>
      <comments>http://www.fluxtah.com/CommentView,guid,73917a6b-9f99-4ca2-94fb-d253359594b4.aspx</comments>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://www.fluxtah.com/Trackback.aspx?guid=d0dc280e-2600-4617-b32a-967223e4ade3</trackback:ping>
      <pingback:server>http://www.fluxtah.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.fluxtah.com/PermaLink,guid,d0dc280e-2600-4617-b32a-967223e4ade3.aspx</pingback:target>
      <dc:creator>Fluxtah</dc:creator>
      <wfw:comment>http://www.fluxtah.com/CommentView,guid,d0dc280e-2600-4617-b32a-967223e4ade3.aspx</wfw:comment>
      <wfw:commentRss>http://www.fluxtah.com/SyndicationService.asmx/GetEntryCommentsRss?guid=d0dc280e-2600-4617-b32a-967223e4ade3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Its common practice to use a user control
in a web part via LoadControl(...). By doing this you get the ASP.NET designer experience
when working with .ascx files.<br /><br />
After seeing some implementations of encapsulating a user control in a web part, I
created a version that uses a generic base class that has the benefits of giving strongly
typed access to the user control, the class is as follows.<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">abstract</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">class</span> UserControlWebPart&lt;T&gt;
: WebPart where T : UserControl { <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">///
&lt;summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">///
The control in the ASCX file</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">///
&lt;/summary&gt;</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">protected</span> T
UserControl { get; set; } <span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">///
&lt;summary&gt;</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">///
Path to the ASCX file</span><span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;">///
&lt;/summary&gt;</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">protected</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">abstract</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">string</span> UserControlPath
{ get; } <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">protected</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">override</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">void</span> CreateChildControls()
{ <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">base</span>.CreateChildControls(); <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">if</span> (!<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">string</span>.IsNullOrEmpty(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">this</span>.UserControlPath))
{ <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">this</span>.UserControl <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span> (T)<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">this</span>.Page.LoadControl(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">this</span>.UserControlPath); <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">this</span>.UserControl.ID <span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"uc"</span>; <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">this</span>.Controls.Add(<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">this</span>.UserControl);
} } <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">protected</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">override</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">void</span> OnLoad(EventArgs
e) { <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">base</span>.OnLoad(e);
EnsureChildControls(); } <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">protected</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">override</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">void</span> Render(HtmlTextWriter
writer) { <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">if</span> (<span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">this</span>.UserControl
!<span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">null</span>)
{ <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">this</span>.UserControl.RenderControl(writer);
} <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">else</span> {
writer.Write(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"UserControlPath
is an invalid path, it must point to a valid .ascx file"</span>); } }</span></pre>To
use this class you can just subclass it and implement the abstract property to define
the path to the ascx file as follows.<br /><br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">class</span> MyWebPartUserControl
: UserControl { } <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">public</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">class</span> MyWebPart
: UserControlWebPart&lt;MyWebPartUserControl&gt; {     <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">protected</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">override</span><span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">string</span> UserControlPath
    {         get { <span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;">return</span><span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"~/_controltemplates/my.user.controls/mywebpartusercontrol.ascx"</span>;
}     } }</span></pre>The MyWebPartUserControl is the code-behind
for the ascx file specified for the abstract UserControlPath property, this file requires
a fully qualified assembly path to work correctly within sharepoint as follows.<br /><pre><span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;">&lt;%@
Assembly Name=<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"My.Assembly,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=1234abcd1234abcd"</span> %&gt; &lt;%@
Control Language=<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"C#"</span> Inherits=<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"My.Assembly.MyWebPartUserControl"</span> %&gt;</span></pre><p></p><img width="0" height="0" src="http://www.fluxtah.com/aggbug.ashx?id=d0dc280e-2600-4617-b32a-967223e4ade3" /></body>
      <title>SharePoint User Controls and Web Parts</title>
      <guid isPermaLink="false">http://www.fluxtah.com/PermaLink,guid,d0dc280e-2600-4617-b32a-967223e4ade3.aspx</guid>
      <link>http://www.fluxtah.com/2009/12/17/SharePointUserControlsAndWebParts.aspx</link>
      <pubDate>Thu, 17 Dec 2009 11:34:00 GMT</pubDate>
      <description>Its common practice to use a user control in a web part via LoadControl(...). By doing this you get the ASP.NET designer experience when working with .ascx files.&lt;br&gt;
&lt;br&gt;
After seeing some implementations of encapsulating a user control in a web part, I
created a version that uses a generic base class that has the benefits of giving strongly
typed access to the user control, the class is as follows.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;abstract&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;class&lt;/span&gt; UserControlWebPart&amp;lt;T&amp;gt;
: WebPart where T : UserControl { &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;///
The control in the ASCX file&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;protected&lt;/span&gt; T
UserControl { get; set; } &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;///
Path to the ASCX file&lt;/span&gt; &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;abstract&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; UserControlPath
{ get; } &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;override&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;void&lt;/span&gt; CreateChildControls()
{ &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;base&lt;/span&gt;.CreateChildControls(); &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; (!&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt;.IsNullOrEmpty(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;.UserControlPath))
{ &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;.UserControl &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; (T)&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;.Page.LoadControl(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;.UserControlPath); &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;.UserControl.ID &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"uc"&lt;/span&gt;; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;.Controls.Add(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;.UserControl);
} } &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;override&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;void&lt;/span&gt; OnLoad(EventArgs
e) { &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;base&lt;/span&gt;.OnLoad(e);
EnsureChildControls(); } &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;override&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;void&lt;/span&gt; Render(HtmlTextWriter
writer) { &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; (&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;.UserControl
!&lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;null&lt;/span&gt;)
{ &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;.UserControl.RenderControl(writer);
} &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;else&lt;/span&gt; {
writer.Write(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"UserControlPath
is an invalid path, it must point to a valid .ascx file"&lt;/span&gt;); } }&lt;/span&gt;&lt;/pre&gt;To
use this class you can just subclass it and implement the abstract property to define
the path to the ascx file as follows.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;class&lt;/span&gt; MyWebPartUserControl
: UserControl { } &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;class&lt;/span&gt; MyWebPart
: UserControlWebPart&amp;lt;MyWebPartUserControl&amp;gt; { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;override&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; UserControlPath
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;get { &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"~/_controltemplates/my.user.controls/mywebpartusercontrol.ascx"&lt;/span&gt;;
} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} }&lt;/span&gt;&lt;/pre&gt;The MyWebPartUserControl is the code-behind
for the ascx file specified for the abstract UserControlPath property, this file requires
a fully qualified assembly path to work correctly within sharepoint as follows.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&amp;lt;%@
Assembly Name=&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"My.Assembly,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=1234abcd1234abcd"&lt;/span&gt; %&amp;gt; &amp;lt;%@
Control Language=&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"C#"&lt;/span&gt; Inherits=&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"My.Assembly.MyWebPartUserControl"&lt;/span&gt; %&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.fluxtah.com/aggbug.ashx?id=d0dc280e-2600-4617-b32a-967223e4ade3" /&gt;</description>
      <comments>http://www.fluxtah.com/CommentView,guid,d0dc280e-2600-4617-b32a-967223e4ade3.aspx</comments>
      <category>Sharepoint</category>
    </item>
    <item>
      <trackback:ping>http://www.fluxtah.com/Trackback.aspx?guid=6f3b62ba-9f1c-4ebc-a577-4ec46b9f9b79</trackback:ping>
      <pingback:server>http://www.fluxtah.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.fluxtah.com/PermaLink,guid,6f3b62ba-9f1c-4ebc-a577-4ec46b9f9b79.aspx</pingback:target>
      <dc:creator>Fluxtah</dc:creator>
      <wfw:comment>http://www.fluxtah.com/CommentView,guid,6f3b62ba-9f1c-4ebc-a577-4ec46b9f9b79.aspx</wfw:comment>
      <wfw:commentRss>http://www.fluxtah.com/SyndicationService.asmx/GetEntryCommentsRss?guid=6f3b62ba-9f1c-4ebc-a577-4ec46b9f9b79</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I created a custom content type and list definition, after upgrading my sharepoint
solution I could see the list and content types under the new menu but when creating
a new item, the fields were missing from NewForm.aspx
</p>
        <p>
I discovered that it was due to the ContentType definition not having the FieldRefs
tag, my content type was defined like this:-
</p>
        <p>
          <font face="Courier New">  &lt;ContentType ID="0x01001376F571B0DB9D4E9384D2927DC110CF02"
Name="News Article" Group="Vodafone LCD Content Types" Version="0"&gt;<br />
  &lt;/ContentType&gt;</font>
        </p>
        <p>
When it should have been like this:-
</p>
        <p>
          <font face="Courier New">  &lt;ContentType ID="0x01001376F571B0DB9D4E9384D2927DC110CF02"
Name="News Article" Group="Vodafone LCD Content Types" Version="0"&gt;<br />
    &lt;FieldRefs&gt;<br />
    &lt;/FieldRefs&gt;<br />
  &lt;/ContentType&gt;</font>
        </p>
        <img width="0" height="0" src="http://www.fluxtah.com/aggbug.ashx?id=6f3b62ba-9f1c-4ebc-a577-4ec46b9f9b79" />
      </body>
      <title>Sharepoint missing fields in NewForm for custom list definition and content type</title>
      <guid isPermaLink="false">http://www.fluxtah.com/PermaLink,guid,6f3b62ba-9f1c-4ebc-a577-4ec46b9f9b79.aspx</guid>
      <link>http://www.fluxtah.com/2009/12/16/SharepointMissingFieldsInNewFormForCustomListDefinitionAndContentType.aspx</link>
      <pubDate>Wed, 16 Dec 2009 08:38:54 GMT</pubDate>
      <description>&lt;p&gt;
I created a custom content type and list definition, after upgrading my sharepoint
solution I could see the list and content types under the new menu but when creating
a new item, the fields were missing from NewForm.aspx
&lt;/p&gt;
&lt;p&gt;
I discovered that it was due to the ContentType definition not having the FieldRefs
tag, my content type was defined like this:-
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp; &amp;lt;ContentType ID="0x01001376F571B0DB9D4E9384D2927DC110CF02"
Name="News Article" Group="Vodafone LCD Content Types" Version="0"&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/ContentType&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
When it should have been like this:-
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp; &amp;lt;ContentType ID="0x01001376F571B0DB9D4E9384D2927DC110CF02"
Name="News Article" Group="Vodafone LCD Content Types" Version="0"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;FieldRefs&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/FieldRefs&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/ContentType&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.fluxtah.com/aggbug.ashx?id=6f3b62ba-9f1c-4ebc-a577-4ec46b9f9b79" /&gt;</description>
      <comments>http://www.fluxtah.com/CommentView,guid,6f3b62ba-9f1c-4ebc-a577-4ec46b9f9b79.aspx</comments>
      <category>Sharepoint</category>
    </item>
    <item>
      <trackback:ping>http://www.fluxtah.com/Trackback.aspx?guid=80e5f632-3cf7-435a-b40a-4fe99849a1a4</trackback:ping>
      <pingback:server>http://www.fluxtah.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.fluxtah.com/PermaLink,guid,80e5f632-3cf7-435a-b40a-4fe99849a1a4.aspx</pingback:target>
      <dc:creator>Fluxtah</dc:creator>
      <wfw:comment>http://www.fluxtah.com/CommentView,guid,80e5f632-3cf7-435a-b40a-4fe99849a1a4.aspx</wfw:comment>
      <wfw:commentRss>http://www.fluxtah.com/SyndicationService.asmx/GetEntryCommentsRss?guid=80e5f632-3cf7-435a-b40a-4fe99849a1a4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was thinking about this, for some reason, and thought it would be good to remind
myself of those little useful bits of code that you never really use much then sometimes
wonder how to do them.
</p>
        <p>
So my first tidbit, is to test if a number is a whole number, here is my solution,
any better solution than this, answers on a postcard please.
</p>
        <pre>
          <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px">
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">void</span> Main()
{ <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">decimal</span> decimalNumber <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> 4.9M; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">decimal</span> wholeNumber <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> 5;
Console.WriteLine(Math.Floor(decimalNumber) == decimalNumber); <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: green; FONT-SIZE: 11px">//
Returns false;</span> Console.WriteLine(Math.Floor(wholeNumber) == wholeNumber); <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: green; FONT-SIZE: 11px">//
Returns true;</span> }</span>
        </pre>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.fluxtah.com/aggbug.ashx?id=80e5f632-3cf7-435a-b40a-4fe99849a1a4" />
      </body>
      <title>Testing for a whole number in C#</title>
      <guid isPermaLink="false">http://www.fluxtah.com/PermaLink,guid,80e5f632-3cf7-435a-b40a-4fe99849a1a4.aspx</guid>
      <link>http://www.fluxtah.com/2009/11/25/TestingForAWholeNumberInC.aspx</link>
      <pubDate>Wed, 25 Nov 2009 10:39:40 GMT</pubDate>
      <description>&lt;p&gt;
I was thinking about this, for some reason, and thought it would be good to remind
myself of those little useful bits of code that you never really use much then sometimes
wonder how to do them.
&lt;/p&gt;
&lt;p&gt;
So my first tidbit, is to test if a number is a whole number, here is my solution,
any better solution than this, answers on a postcard please.
&lt;/p&gt;
&lt;pre&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;void&lt;/span&gt; Main()
{ &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;decimal&lt;/span&gt; decimalNumber &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; 4.9M; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;decimal&lt;/span&gt; wholeNumber &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; 5;
Console.WriteLine(Math.Floor(decimalNumber) == decimalNumber); &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: green; FONT-SIZE: 11px"&gt;//
Returns false;&lt;/span&gt; Console.WriteLine(Math.Floor(wholeNumber) == wholeNumber); &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: green; FONT-SIZE: 11px"&gt;//
Returns true;&lt;/span&gt; }&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.fluxtah.com/aggbug.ashx?id=80e5f632-3cf7-435a-b40a-4fe99849a1a4" /&gt;</description>
      <comments>http://www.fluxtah.com/CommentView,guid,80e5f632-3cf7-435a-b40a-4fe99849a1a4.aspx</comments>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://www.fluxtah.com/Trackback.aspx?guid=14c30b90-767b-4c0a-8c14-5354601d5437</trackback:ping>
      <pingback:server>http://www.fluxtah.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.fluxtah.com/PermaLink,guid,14c30b90-767b-4c0a-8c14-5354601d5437.aspx</pingback:target>
      <dc:creator>Fluxtah</dc:creator>
      <wfw:comment>http://www.fluxtah.com/CommentView,guid,14c30b90-767b-4c0a-8c14-5354601d5437.aspx</wfw:comment>
      <wfw:commentRss>http://www.fluxtah.com/SyndicationService.asmx/GetEntryCommentsRss?guid=14c30b90-767b-4c0a-8c14-5354601d5437</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I wrote a small console application to test if this was possible and it turns out
all you need is an <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlincludeattribute.aspx">XmlInclude</a> attribute
on the base type of the sub-types you are serializing.
</p>
        <p>
In the following example <font face="Courier New">Ninja</font> and <font face="Courier New">Customer</font> inherit
from <font face="Courier New">Person</font>, Person is decorated with the <font face="Courier New">XmlInclude</font> attribute
for both <font face="Courier New">Ninja</font> and <font face="Courier New">Customer</font>.
</p>
        <pre>
          <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px">
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">class</span> Program
{ <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">static</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">void</span> Main(<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">string</span>[]
args) { XmlSerializer serializer <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">new</span> XmlSerializer(<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">typeof</span>(Stuff));
Stuff stuff <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">new</span> Stuff()
{ People <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">new</span> List&lt;Person&gt;()
{ <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">new</span> Person()
{ Name <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span><span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">"&lt;b&gt;Bob&lt;/b&gt;"</span>,
Type=<span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">"Person"</span> }, <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">new</span> Ninja()
{ Name <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span><span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">"Hiro"</span>,
Type=<span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">"Ninja"</span>,
Weapon <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span><span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">"Shuriken"</span> }, <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">new</span> Customer()
{ Name <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span><span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">"Fred"</span>,
Type <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span><span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">"Customer"</span>,
CustomerId <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span><span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">"1234"</span>}
} }; serializer.Serialize(Console.Out, stuff); } } <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">class</span> Stuff
{ <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span> List&lt;Person&gt;
People { get; set; } } <strong> [XmlInclude(<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">typeof</span>(Ninja)),
XmlInclude(<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">typeof</span>(Customer))]</strong><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">class</span> Person
{ <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">string</span> Type
{ get; set; } <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">string</span> Name
{ get; set; } } <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">class</span> Ninja
: Person { <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">string</span> Weapon
{ get; set; } } <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">class</span> Customer
: Person { <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">string</span> CustomerId
{ get; set; } }</span>
        </pre>
        <img width="0" height="0" src="http://www.fluxtah.com/aggbug.ashx?id=14c30b90-767b-4c0a-8c14-5354601d5437" />
      </body>
      <title>C# XML serialization and inheritance</title>
      <guid isPermaLink="false">http://www.fluxtah.com/PermaLink,guid,14c30b90-767b-4c0a-8c14-5354601d5437.aspx</guid>
      <link>http://www.fluxtah.com/2009/11/13/CXMLSerializationAndInheritance.aspx</link>
      <pubDate>Fri, 13 Nov 2009 07:56:37 GMT</pubDate>
      <description>&lt;p&gt;
I wrote a small console application to test if this was possible and it turns out
all you need is an &lt;a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlincludeattribute.aspx"&gt;XmlInclude&lt;/a&gt; attribute
on the base type of the sub-types you are serializing.
&lt;/p&gt;
&lt;p&gt;
In the following example &lt;font face="Courier New"&gt;Ninja&lt;/font&gt; and &lt;font face="Courier New"&gt;Customer&lt;/font&gt; inherit
from &lt;font face="Courier New"&gt;Person&lt;/font&gt;, Person is decorated with the &lt;font face="Courier New"&gt;XmlInclude&lt;/font&gt; attribute
for both &lt;font face="Courier New"&gt;Ninja&lt;/font&gt; and &lt;font face="Courier New"&gt;Customer&lt;/font&gt;.
&lt;/p&gt;
&lt;pre&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;class&lt;/span&gt; Program
{ &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;static&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;void&lt;/span&gt; Main(&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;string&lt;/span&gt;[]
args) { XmlSerializer serializer &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;new&lt;/span&gt; XmlSerializer(&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;typeof&lt;/span&gt;(Stuff));
Stuff stuff &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;new&lt;/span&gt; Stuff()
{ People &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;new&lt;/span&gt; List&amp;lt;Person&amp;gt;()
{ &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;new&lt;/span&gt; Person()
{ Name &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;"&amp;lt;b&amp;gt;Bob&amp;lt;/b&amp;gt;"&lt;/span&gt;,
Type=&lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;"Person"&lt;/span&gt; }, &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;new&lt;/span&gt; Ninja()
{ Name &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;"Hiro"&lt;/span&gt;,
Type=&lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;"Ninja"&lt;/span&gt;,
Weapon &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;"Shuriken"&lt;/span&gt; }, &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;new&lt;/span&gt; Customer()
{ Name &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;"Fred"&lt;/span&gt;,
Type &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;"Customer"&lt;/span&gt;,
CustomerId &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;"1234"&lt;/span&gt;}
} }; serializer.Serialize(Console.Out, stuff); } } &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;class&lt;/span&gt; Stuff
{ &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; List&amp;lt;Person&amp;gt;
People { get; set; } } &lt;strong&gt; [XmlInclude(&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;typeof&lt;/span&gt;(Ninja)),
XmlInclude(&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;typeof&lt;/span&gt;(Customer))]&lt;/strong&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;class&lt;/span&gt; Person
{ &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;string&lt;/span&gt; Type
{ get; set; } &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;string&lt;/span&gt; Name
{ get; set; } } &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;class&lt;/span&gt; Ninja
: Person { &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;string&lt;/span&gt; Weapon
{ get; set; } } &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;class&lt;/span&gt; Customer
: Person { &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;string&lt;/span&gt; CustomerId
{ get; set; } }&lt;/span&gt;&lt;/pre&gt;&lt;img width="0" height="0" src="http://www.fluxtah.com/aggbug.ashx?id=14c30b90-767b-4c0a-8c14-5354601d5437" /&gt;</description>
      <comments>http://www.fluxtah.com/CommentView,guid,14c30b90-767b-4c0a-8c14-5354601d5437.aspx</comments>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://www.fluxtah.com/Trackback.aspx?guid=5f1a8d18-251a-49d2-9619-fb34b1ab8892</trackback:ping>
      <pingback:server>http://www.fluxtah.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.fluxtah.com/PermaLink,guid,5f1a8d18-251a-49d2-9619-fb34b1ab8892.aspx</pingback:target>
      <dc:creator>Fluxtah</dc:creator>
      <wfw:comment>http://www.fluxtah.com/CommentView,guid,5f1a8d18-251a-49d2-9619-fb34b1ab8892.aspx</wfw:comment>
      <wfw:commentRss>http://www.fluxtah.com/SyndicationService.asmx/GetEntryCommentsRss?guid=5f1a8d18-251a-49d2-9619-fb34b1ab8892</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
It comes to that point in time when you need a country table in your database
and you do not have a list to import at hand, after scouring the web a bit, everything
seemed to be out of date, so I wrote a little script to scrape the details from a
wikipedia page for the <a href="http://en.wikipedia.org/wiki/ISO_3166-1" target="_blank">ISO
3166-1 standard for country codes</a>.
</p>
        <p>
I wrote and ran the following quick &amp; dirty JQuery script on that page.
</p>
        <pre>
          <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px">
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">if</span>($('#output_textarea').<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">length</span> ==
0){ $(document.body).append($('&lt;textarea rows=<span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">"128"</span> id=<span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">"output_textarea"</span>&gt;&lt;/textarea&gt;'));
} document.output_textarea_val <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span><span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">""</span>;
$('#sortable_table_id_0 tr').each(<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">function</span>(idx){ <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">if</span>(idx
&gt; 0){ document.output_textarea_val += <span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">"INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">var</span> cells <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> $('td', <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">this</span>),
cellLen <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> cells.<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">length</span>;
cells.each(<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">function</span>(cellIdx){ <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">if</span>(cellIdx
&lt; 4){ document.output_textarea_val += <span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">"\""</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">+</span> $(<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">this</span>).text().trim() <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">+</span><span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">"\""</span>; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">if</span>(cellIdx
&lt; cellLen <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">-</span> 2){
document.output_textarea_val += <span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px">",
"</span>; } } }); document.output_textarea_val += ');\n'; } }); $('#output_textarea').val(document.output_textarea_val);</span>
        </pre>
        <p>
This script creates insert statements for mySQL and inserts the results into a text
box at the foot of the page, in order for it to work you need to inject jQuery into
the document, you can do this with the <a href="javascript:var%20s=document.createElement('script');s.setAttribute('src',%20'http://jquery.com/src/jquery-latest.js');document.getElementsByTagName('body')[0].appendChild(s);alert('thank%20you%20for%20using%20jquery!');void(s);">jQueryify
Bookmarklet</a>.
</p>
        <p>
I have tested this script and it qualifies for the <a href="http://www.codinghorror.com/blog/archives/000818.html">"works
on my machine" certification programme</a>.
</p>
        <p>
          <img border="0" src="http://www.fluxtah.com/content/binary/works-on-my-machine-starburst.png" />
        </p>
        <p>
The script produces the following output.
</p>
        <p>
          <textarea style="WIDTH: 100%; HEIGHT: 262px">INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Afghanistan", "AF", "AFG", "004"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Aland Islands ﻿ Åland
Islands", "AX", "ALA", "248"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Albania", "AL", "ALB", "008"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Algeria", "DZ", "DZA", "012"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("American Samoa", "AS", "ASM",
"016"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Andorra",
"AD", "AND", "020"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Angola", "AO", "AGO", "024"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Anguilla", "AI", "AIA", "660"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Antarctica", "AQ", "ATA", "010"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Antigua and Barbuda",
"AG", "ATG", "028"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Argentina", "AR", "ARG", "032"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Armenia", "AM", "ARM", "051"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Aruba", "AW", "ABW", "533");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Australia",
"AU", "AUS", "036"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Austria", "AT", "AUT", "040"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Azerbaijan", "AZ", "AZE", "031"); INSERT INTO country (name,
code_alpha_2, code_alpha_3, code_numeric) VALUES("Bahamas", "BS", "BHS", "044"); INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Bahrain", "BH",
"BHR", "048"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Bangladesh", "BD", "BGD", "050"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Barbados", "BB", "BRB", "052"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Belarus", "BY", "BLR", "112");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Belgium",
"BE", "BEL", "056"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Belize", "BZ", "BLZ", "084"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Benin", "BJ", "BEN", "204"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Bermuda", "BM", "BMU", "060"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Bhutan", "BT", "BTN", "064");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Bolivia,
Plurinational State of", "BO", "BOL", "068"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Bosnia and Herzegovina", "BA", "BIH", "070");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Botswana",
"BW", "BWA", "072"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Bouvet Island", "BV", "BVT", "074"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Brazil", "BR", "BRA", "076"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("British Indian Ocean Territory",
"IO", "IOT", "086"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Brunei Darussalam", "BN", "BRN", "096"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Bulgaria", "BG", "BGR", "100"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Burkina Faso", "BF", "BFA",
"854"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Burundi",
"BI", "BDI", "108"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Cambodia", "KH", "KHM", "116"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Cameroon", "CM", "CMR", "120"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Canada", "CA", "CAN", "124"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Cape Verde", "CV", "CPV",
"132"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Cayman
Islands", "KY", "CYM", "136"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Central African Republic", "CF", "CAF", "140"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Chad", "TD", "TCD",
"148"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Chile",
"CL", "CHL", "152"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("China", "CN", "CHN", "156"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Christmas Island", "CX", "CXR", "162"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Cocos (Keeling) Islands",
"CC", "CCK", "166"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Colombia", "CO", "COL", "170"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Comoros", "KM", "COM", "174"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Congo", "CG", "COG", "178"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Congo, the Democratic Republic
of the", "CD", "COD", "180"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Cook Islands", "CK", "COK", "184"); INSERT INTO country (name,
code_alpha_2, code_alpha_3, code_numeric) VALUES("Costa Rica", "CR", "CRI", "188");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Cote
d'Ivoire ﻿ Côte d'Ivoire", "CI", "CIV", "384"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Croatia", "HR", "HRV", "191"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Cuba", "CU", "CUB", "192");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Cyprus",
"CY", "CYP", "196"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Czech Republic", "CZ", "CZE", "203"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Denmark", "DK", "DNK", "208"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Djibouti", "DJ", "DJI", "262");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Dominica",
"DM", "DMA", "212"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Dominican Republic", "DO", "DOM", "214"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Ecuador", "EC", "ECU", "218"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Egypt", "EG", "EGY", "818");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("El Salvador",
"SV", "SLV", "222"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Equatorial Guinea", "GQ", "GNQ", "226"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Eritrea", "ER", "ERI", "232"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Estonia", "EE", "EST", "233");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Ethiopia",
"ET", "ETH", "231"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Falkland Islands (Malvinas)", "FK", "FLK", "238"); INSERT INTO country (name,
code_alpha_2, code_alpha_3, code_numeric) VALUES("Faroe Islands", "FO", "FRO", "234");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Fiji",
"FJ", "FJI", "242"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Finland", "FI", "FIN", "246"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("France", "FR", "FRA", "250"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("French Guiana", "GF", "GUF", "254"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("French Polynesia",
"PF", "PYF", "258"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("French Southern Territories", "TF", "ATF", "260"); INSERT INTO country (name,
code_alpha_2, code_alpha_3, code_numeric) VALUES("Gabon", "GA", "GAB", "266"); INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Gambia", "GM",
"GMB", "270"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Georgia", "GE", "GEO", "268"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Germany", "DE", "DEU", "276"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Ghana", "GH", "GHA", "288"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Gibraltar", "GI", "GIB",
"292"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Greece",
"GR", "GRC", "300"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Greenland", "GL", "GRL", "304"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Grenada", "GD", "GRD", "308"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Guadeloupe", "GP", "GLP",
"312"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Guam",
"GU", "GUM", "316"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Guatemala", "GT", "GTM", "320"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Guernsey", "GG", "GGY", "831"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Guinea", "GN", "GIN", "324");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Guinea-Bissau",
"GW", "GNB", "624"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Guyana", "GY", "GUY", "328"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Haiti", "HT", "HTI", "332"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Heard Island and McDonald Islands", "HM", "HMD",
"334"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Holy
See (Vatican City State)", "VA", "VAT", "336"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Honduras", "HN", "HND", "340"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Hong Kong", "HK", "HKG",
"344"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Hungary",
"HU", "HUN", "348"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Iceland", "IS", "ISL", "352"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("India", "IN", "IND", "356"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Indonesia", "ID", "IDN", "360"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Iran, Islamic Republic of",
"IR", "IRN", "364"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Iraq", "IQ", "IRQ", "368"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Ireland", "IE", "IRL", "372"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Isle of Man", "IM", "IMN", "833"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Israel", "IL", "ISR",
"376"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Italy",
"IT", "ITA", "380"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Jamaica", "JM", "JAM", "388"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Japan", "JP", "JPN", "392"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Jersey", "JE", "JEY", "832"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Jordan", "JO", "JOR", "400");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Kazakhstan",
"KZ", "KAZ", "398"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Kenya", "KE", "KEN", "404"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Kiribati", "KI", "KIR", "296"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Korea, Democratic People's Republic of", "KP",
"PRK", "408"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Korea, Republic of", "KR", "KOR", "410"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Kuwait", "KW", "KWT", "414"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Kyrgyzstan", "KG", "KGZ",
"417"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Lao
People's Democratic Republic", "LA", "LAO", "418"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Latvia", "LV", "LVA", "428"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Lebanon", "LB", "LBN", "422");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Lesotho",
"LS", "LSO", "426"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Liberia", "LR", "LBR", "430"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Libyan Arab Jamahiriya", "LY", "LBY", "434"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Liechtenstein", "LI", "LIE",
"438"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Lithuania",
"LT", "LTU", "440"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Luxembourg", "LU", "LUX", "442"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Macao", "MO", "MAC", "446"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Macedonia, the former Yugoslav
Republic of", "MK", "MKD", "807"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Madagascar", "MG", "MDG", "450"); INSERT INTO country (name,
code_alpha_2, code_alpha_3, code_numeric) VALUES("Malawi", "MW", "MWI", "454"); INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Malaysia", "MY",
"MYS", "458"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Maldives", "MV", "MDV", "462"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Mali", "ML", "MLI", "466"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Malta", "MT", "MLT", "470"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Marshall Islands", "MH",
"MHL", "584"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Martinique", "MQ", "MTQ", "474"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Mauritania", "MR", "MRT", "478"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Mauritius", "MU",
"MUS", "480"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Mayotte", "YT", "MYT", "175"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Mexico", "MX", "MEX", "484"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Micronesia, Federated States of", "FM", "FSM",
"583"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Moldova,
Republic of", "MD", "MDA", "498"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Monaco", "MC", "MCO", "492"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Mongolia", "MN", "MNG", "496"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Montenegro", "ME", "MNE",
"499"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Montserrat",
"MS", "MSR", "500"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Morocco", "MA", "MAR", "504"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Mozambique", "MZ", "MOZ", "508"); INSERT INTO country (name,
code_alpha_2, code_alpha_3, code_numeric) VALUES("Myanmar", "MM", "MMR", "104"); INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Namibia", "NA",
"NAM", "516"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Nauru", "NR", "NRU", "520"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Nepal", "NP", "NPL", "524"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Netherlands", "NL", "NLD", "528"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Netherlands Antilles",
"AN", "ANT", "530"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("New Caledonia", "NC", "NCL", "540"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("New Zealand", "NZ", "NZL", "554"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Nicaragua", "NI",
"NIC", "558"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Niger", "NE", "NER", "562"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Nigeria", "NG", "NGA", "566"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Niue", "NU", "NIU", "570"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Norfolk Island", "NF", "NFK",
"574"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Northern
Mariana Islands", "MP", "MNP", "580"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Norway", "NO", "NOR", "578"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Oman", "OM", "OMN", "512"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Pakistan", "PK", "PAK", "586");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Palau",
"PW", "PLW", "585"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Palestinian Territory, Occupied", "PS", "PSE", "275"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Panama", "PA", "PAN", "591");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Papua
New Guinea", "PG", "PNG", "598"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Paraguay", "PY", "PRY", "600"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Peru", "PE", "PER", "604"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Philippines", "PH", "PHL",
"608"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Pitcairn",
"PN", "PCN", "612"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Poland", "PL", "POL", "616"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Portugal", "PT", "PRT", "620"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Puerto Rico", "PR", "PRI", "630"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Qatar", "QA", "QAT",
"634"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Reunion
﻿ Réunion", "RE", "REU", "638"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Romania", "RO", "ROU", "642"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Russian Federation", "RU", "RUS", "643"); INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Rwanda", "RW",
"RWA", "646"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Saint Barthélemy", "BL", "BLM", "652"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Saint Helena", "SH", "SHN", "654"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Saint Kitts and Nevis",
"KN", "KNA", "659"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Saint Lucia", "LC", "LCA", "662"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Saint Martin (French part)", "MF", "MAF", "663");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Saint
Pierre and Miquelon", "PM", "SPM", "666"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Saint Vincent and the Grenadines", "VC", "VCT",
"670"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Samoa",
"WS", "WSM", "882"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("San Marino", "SM", "SMR", "674"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Sao Tome and Principe", "ST", "STP", "678"); INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Saudi Arabia",
"SA", "SAU", "682"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Senegal", "SN", "SEN", "686"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Serbia", "RS", "SRB", "688"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Seychelles", "SC", "SYC", "690"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Sierra Leone", "SL",
"SLE", "694"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Singapore", "SG", "SGP", "702"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Slovakia", "SK", "SVK", "703"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Slovenia", "SI", "SVN", "705");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Solomon
Islands", "SB", "SLB", "090"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Somalia", "SO", "SOM", "706"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("South Africa", "ZA", "ZAF", "710"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("South Georgia and
the South Sandwich Islands", "GS", "SGS", "239"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Spain", "ES", "ESP", "724"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Sri Lanka", "LK", "LKA",
"144"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Sudan",
"SD", "SDN", "736"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Suriname", "SR", "SUR", "740"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Svalbard and Jan Mayen", "SJ", "SJM", "744"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Swaziland", "SZ", "SWZ",
"748"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Sweden",
"SE", "SWE", "752"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Switzerland", "CH", "CHE", "756"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Syrian Arab Republic", "SY", "SYR", "760"); INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Taiwan, Province
of China", "TW", "TWN", "158"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Tajikistan", "TJ", "TJK", "762"); INSERT INTO country (name,
code_alpha_2, code_alpha_3, code_numeric) VALUES("Tanzania, United Republic of", "TZ",
"TZA", "834"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Thailand", "TH", "THA", "764"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Timor-Leste", "TL", "TLS", "626"); INSERT INTO country (name,
code_alpha_2, code_alpha_3, code_numeric) VALUES("Togo", "TG", "TGO", "768"); INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Tokelau", "TK",
"TKL", "772"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Tonga", "TO", "TON", "776"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Trinidad and Tobago", "TT", "TTO", "780"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Tunisia", "TN", "TUN", "788");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Turkey",
"TR", "TUR", "792"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Turkmenistan", "TM", "TKM", "795"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Turks and Caicos Islands", "TC", "TCA", "796");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Tuvalu",
"TV", "TUV", "798"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Uganda", "UG", "UGA", "800"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Ukraine", "UA", "UKR", "804"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("United Arab Emirates", "AE", "ARE", "784"); INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("United Kingdom",
"GB", "GBR", "826"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("United States", "US", "USA", "840"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("United States Minor Outlying Islands", "UM", "UMI",
"581"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Uruguay",
"UY", "URY", "858"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Uzbekistan", "UZ", "UZB", "860"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Vanuatu", "VU", "VUT", "548"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Venezuela, Bolivarian Republic
of", "VE", "VEN", "862"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Viet Nam", "VN", "VNM", "704"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Virgin Islands, British", "VG", "VGB", "092"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Virgin Islands, U.S.", "VI",
"VIR", "850"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Wallis and Futuna", "WF", "WLF", "876"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Western Sahara", "EH", "ESH", "732"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Yemen", "YE", "YEM",
"887"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Zambia",
"ZM", "ZMB", "894"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Zimbabwe", "ZW", "ZWE", "716"); </textarea>
        </p>
        <img width="0" height="0" src="http://www.fluxtah.com/aggbug.ashx?id=5f1a8d18-251a-49d2-9619-fb34b1ab8892" />
      </body>
      <title>Country table data sql script</title>
      <guid isPermaLink="false">http://www.fluxtah.com/PermaLink,guid,5f1a8d18-251a-49d2-9619-fb34b1ab8892.aspx</guid>
      <link>http://www.fluxtah.com/2009/11/11/CountryTableDataSqlScript.aspx</link>
      <pubDate>Wed, 11 Nov 2009 13:07:31 GMT</pubDate>
      <description>&lt;p&gt;
It comes to that point in time&amp;nbsp;when you need a country table in your database
and you do not have a list to import&amp;nbsp;at hand, after scouring the web a bit, everything
seemed to be out of date, so I wrote a little script to scrape the details from a
wikipedia page for the &lt;a href="http://en.wikipedia.org/wiki/ISO_3166-1" target=_blank&gt;ISO
3166-1 standard for country codes&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
I wrote and ran the following quick &amp;amp;&amp;nbsp;dirty JQuery&amp;nbsp;script on that page.
&lt;/p&gt;
&lt;pre&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;if&lt;/span&gt;($('#output_textarea').&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;length&lt;/span&gt; ==
0){ $(document.body).append($('&amp;lt;textarea rows=&lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;"128"&lt;/span&gt; id=&lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;"output_textarea"&lt;/span&gt;&amp;gt;&amp;lt;/textarea&amp;gt;'));
} document.output_textarea_val &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;""&lt;/span&gt;;
$('#sortable_table_id_0 tr').each(&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;function&lt;/span&gt;(idx){ &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;if&lt;/span&gt;(idx
&amp;gt; 0){ document.output_textarea_val += &lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;"INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;var&lt;/span&gt; cells &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; $('td', &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;this&lt;/span&gt;),
cellLen &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; cells.&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;length&lt;/span&gt;;
cells.each(&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;function&lt;/span&gt;(cellIdx){ &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;if&lt;/span&gt;(cellIdx
&amp;lt; 4){ document.output_textarea_val += &lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;"\""&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;+&lt;/span&gt; $(&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;this&lt;/span&gt;).text().trim() &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;+&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;"\""&lt;/span&gt;; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;if&lt;/span&gt;(cellIdx
&amp;lt; cellLen &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;-&lt;/span&gt; 2){
document.output_textarea_val += &lt;span style="BACKGROUND-COLOR: #e4e4e4; FONT-FAMILY: Courier New; COLOR: #666666; FONT-SIZE: 11px"&gt;",
"&lt;/span&gt;; } } }); document.output_textarea_val += ');\n'; } }); $('#output_textarea').val(document.output_textarea_val);&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
This script creates insert statements for mySQL and inserts the results into a text
box at the foot of the page, in order for it to work you need to inject jQuery into
the document, you can do this with the &lt;a href="javascript:var%20s=document.createElement('script');s.setAttribute('src',%20'http://jquery.com/src/jquery-latest.js');document.getElementsByTagName('body')[0].appendChild(s);alert('thank%20you%20for%20using%20jquery!');void(s);"&gt;jQueryify
Bookmarklet&lt;/a&gt;.&gt;&gt;
&lt;/p&gt;
&lt;p&gt;
I have tested this script and it qualifies for the &lt;a href="http://www.codinghorror.com/blog/archives/000818.html"&gt;"works
on my machine" certification programme&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;img border=0 src="http://www.fluxtah.com/content/binary/works-on-my-machine-starburst.png"&gt;
&lt;/p&gt;
&lt;p&gt;
The script produces the following output.
&lt;/p&gt;
&lt;p&gt;
&lt;textarea style="WIDTH: 100%; HEIGHT: 262px"&gt;INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Afghanistan", "AF", "AFG", "004"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Aland Islands ﻿ Åland
Islands", "AX", "ALA", "248"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Albania", "AL", "ALB", "008"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Algeria", "DZ", "DZA", "012"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("American Samoa", "AS", "ASM",
"016"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Andorra",
"AD", "AND", "020"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Angola", "AO", "AGO", "024"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Anguilla", "AI", "AIA", "660"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Antarctica", "AQ", "ATA", "010"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Antigua and Barbuda",
"AG", "ATG", "028"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Argentina", "AR", "ARG", "032"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Armenia", "AM", "ARM", "051"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Aruba", "AW", "ABW", "533");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Australia",
"AU", "AUS", "036"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Austria", "AT", "AUT", "040"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Azerbaijan", "AZ", "AZE", "031"); INSERT INTO country (name,
code_alpha_2, code_alpha_3, code_numeric) VALUES("Bahamas", "BS", "BHS", "044"); INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Bahrain", "BH",
"BHR", "048"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Bangladesh", "BD", "BGD", "050"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Barbados", "BB", "BRB", "052"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Belarus", "BY", "BLR", "112");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Belgium",
"BE", "BEL", "056"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Belize", "BZ", "BLZ", "084"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Benin", "BJ", "BEN", "204"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Bermuda", "BM", "BMU", "060"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Bhutan", "BT", "BTN", "064");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Bolivia,
Plurinational State of", "BO", "BOL", "068"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Bosnia and Herzegovina", "BA", "BIH", "070");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Botswana",
"BW", "BWA", "072"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Bouvet Island", "BV", "BVT", "074"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Brazil", "BR", "BRA", "076"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("British Indian Ocean Territory",
"IO", "IOT", "086"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Brunei Darussalam", "BN", "BRN", "096"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Bulgaria", "BG", "BGR", "100"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Burkina Faso", "BF", "BFA",
"854"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Burundi",
"BI", "BDI", "108"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Cambodia", "KH", "KHM", "116"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Cameroon", "CM", "CMR", "120"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Canada", "CA", "CAN", "124"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Cape Verde", "CV", "CPV",
"132"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Cayman
Islands", "KY", "CYM", "136"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Central African Republic", "CF", "CAF", "140"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Chad", "TD", "TCD",
"148"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Chile",
"CL", "CHL", "152"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("China", "CN", "CHN", "156"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Christmas Island", "CX", "CXR", "162"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Cocos (Keeling) Islands",
"CC", "CCK", "166"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Colombia", "CO", "COL", "170"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Comoros", "KM", "COM", "174"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Congo", "CG", "COG", "178"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Congo, the Democratic Republic
of the", "CD", "COD", "180"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Cook Islands", "CK", "COK", "184"); INSERT INTO country (name,
code_alpha_2, code_alpha_3, code_numeric) VALUES("Costa Rica", "CR", "CRI", "188");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Cote
d'Ivoire ﻿ Côte d'Ivoire", "CI", "CIV", "384"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Croatia", "HR", "HRV", "191"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Cuba", "CU", "CUB", "192");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Cyprus",
"CY", "CYP", "196"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Czech Republic", "CZ", "CZE", "203"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Denmark", "DK", "DNK", "208"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Djibouti", "DJ", "DJI", "262");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Dominica",
"DM", "DMA", "212"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Dominican Republic", "DO", "DOM", "214"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Ecuador", "EC", "ECU", "218"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Egypt", "EG", "EGY", "818");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("El Salvador",
"SV", "SLV", "222"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Equatorial Guinea", "GQ", "GNQ", "226"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Eritrea", "ER", "ERI", "232"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Estonia", "EE", "EST", "233");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Ethiopia",
"ET", "ETH", "231"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Falkland Islands (Malvinas)", "FK", "FLK", "238"); INSERT INTO country (name,
code_alpha_2, code_alpha_3, code_numeric) VALUES("Faroe Islands", "FO", "FRO", "234");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Fiji",
"FJ", "FJI", "242"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Finland", "FI", "FIN", "246"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("France", "FR", "FRA", "250"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("French Guiana", "GF", "GUF", "254"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("French Polynesia",
"PF", "PYF", "258"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("French Southern Territories", "TF", "ATF", "260"); INSERT INTO country (name,
code_alpha_2, code_alpha_3, code_numeric) VALUES("Gabon", "GA", "GAB", "266"); INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Gambia", "GM",
"GMB", "270"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Georgia", "GE", "GEO", "268"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Germany", "DE", "DEU", "276"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Ghana", "GH", "GHA", "288"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Gibraltar", "GI", "GIB",
"292"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Greece",
"GR", "GRC", "300"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Greenland", "GL", "GRL", "304"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Grenada", "GD", "GRD", "308"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Guadeloupe", "GP", "GLP",
"312"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Guam",
"GU", "GUM", "316"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Guatemala", "GT", "GTM", "320"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Guernsey", "GG", "GGY", "831"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Guinea", "GN", "GIN", "324");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Guinea-Bissau",
"GW", "GNB", "624"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Guyana", "GY", "GUY", "328"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Haiti", "HT", "HTI", "332"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Heard Island and McDonald Islands", "HM", "HMD",
"334"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Holy
See (Vatican City State)", "VA", "VAT", "336"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Honduras", "HN", "HND", "340"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Hong Kong", "HK", "HKG",
"344"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Hungary",
"HU", "HUN", "348"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Iceland", "IS", "ISL", "352"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("India", "IN", "IND", "356"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Indonesia", "ID", "IDN", "360"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Iran, Islamic Republic of",
"IR", "IRN", "364"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Iraq", "IQ", "IRQ", "368"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Ireland", "IE", "IRL", "372"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Isle of Man", "IM", "IMN", "833"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Israel", "IL", "ISR",
"376"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Italy",
"IT", "ITA", "380"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Jamaica", "JM", "JAM", "388"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Japan", "JP", "JPN", "392"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Jersey", "JE", "JEY", "832"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Jordan", "JO", "JOR", "400");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Kazakhstan",
"KZ", "KAZ", "398"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Kenya", "KE", "KEN", "404"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Kiribati", "KI", "KIR", "296"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Korea, Democratic People's Republic of", "KP",
"PRK", "408"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Korea, Republic of", "KR", "KOR", "410"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Kuwait", "KW", "KWT", "414"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Kyrgyzstan", "KG", "KGZ",
"417"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Lao
People's Democratic Republic", "LA", "LAO", "418"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Latvia", "LV", "LVA", "428"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Lebanon", "LB", "LBN", "422");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Lesotho",
"LS", "LSO", "426"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Liberia", "LR", "LBR", "430"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Libyan Arab Jamahiriya", "LY", "LBY", "434"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Liechtenstein", "LI", "LIE",
"438"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Lithuania",
"LT", "LTU", "440"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Luxembourg", "LU", "LUX", "442"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Macao", "MO", "MAC", "446"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Macedonia, the former Yugoslav
Republic of", "MK", "MKD", "807"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Madagascar", "MG", "MDG", "450"); INSERT INTO country (name,
code_alpha_2, code_alpha_3, code_numeric) VALUES("Malawi", "MW", "MWI", "454"); INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Malaysia", "MY",
"MYS", "458"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Maldives", "MV", "MDV", "462"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Mali", "ML", "MLI", "466"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Malta", "MT", "MLT", "470"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Marshall Islands", "MH",
"MHL", "584"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Martinique", "MQ", "MTQ", "474"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Mauritania", "MR", "MRT", "478"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Mauritius", "MU",
"MUS", "480"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Mayotte", "YT", "MYT", "175"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Mexico", "MX", "MEX", "484"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Micronesia, Federated States of", "FM", "FSM",
"583"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Moldova,
Republic of", "MD", "MDA", "498"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Monaco", "MC", "MCO", "492"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Mongolia", "MN", "MNG", "496"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Montenegro", "ME", "MNE",
"499"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Montserrat",
"MS", "MSR", "500"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Morocco", "MA", "MAR", "504"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Mozambique", "MZ", "MOZ", "508"); INSERT INTO country (name,
code_alpha_2, code_alpha_3, code_numeric) VALUES("Myanmar", "MM", "MMR", "104"); INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Namibia", "NA",
"NAM", "516"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Nauru", "NR", "NRU", "520"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Nepal", "NP", "NPL", "524"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Netherlands", "NL", "NLD", "528"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Netherlands Antilles",
"AN", "ANT", "530"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("New Caledonia", "NC", "NCL", "540"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("New Zealand", "NZ", "NZL", "554"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Nicaragua", "NI",
"NIC", "558"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Niger", "NE", "NER", "562"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Nigeria", "NG", "NGA", "566"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Niue", "NU", "NIU", "570"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Norfolk Island", "NF", "NFK",
"574"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Northern
Mariana Islands", "MP", "MNP", "580"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Norway", "NO", "NOR", "578"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Oman", "OM", "OMN", "512"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Pakistan", "PK", "PAK", "586");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Palau",
"PW", "PLW", "585"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Palestinian Territory, Occupied", "PS", "PSE", "275"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Panama", "PA", "PAN", "591");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Papua
New Guinea", "PG", "PNG", "598"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Paraguay", "PY", "PRY", "600"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Peru", "PE", "PER", "604"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Philippines", "PH", "PHL",
"608"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Pitcairn",
"PN", "PCN", "612"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Poland", "PL", "POL", "616"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Portugal", "PT", "PRT", "620"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Puerto Rico", "PR", "PRI", "630"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Qatar", "QA", "QAT",
"634"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Reunion
﻿ Réunion", "RE", "REU", "638"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Romania", "RO", "ROU", "642"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Russian Federation", "RU", "RUS", "643"); INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Rwanda", "RW",
"RWA", "646"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Saint Barthélemy", "BL", "BLM", "652"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Saint Helena", "SH", "SHN", "654"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Saint Kitts and Nevis",
"KN", "KNA", "659"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Saint Lucia", "LC", "LCA", "662"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Saint Martin (French part)", "MF", "MAF", "663");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Saint
Pierre and Miquelon", "PM", "SPM", "666"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Saint Vincent and the Grenadines", "VC", "VCT",
"670"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Samoa",
"WS", "WSM", "882"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("San Marino", "SM", "SMR", "674"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Sao Tome and Principe", "ST", "STP", "678"); INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Saudi Arabia",
"SA", "SAU", "682"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Senegal", "SN", "SEN", "686"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Serbia", "RS", "SRB", "688"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Seychelles", "SC", "SYC", "690"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Sierra Leone", "SL",
"SLE", "694"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Singapore", "SG", "SGP", "702"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Slovakia", "SK", "SVK", "703"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Slovenia", "SI", "SVN", "705");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Solomon
Islands", "SB", "SLB", "090"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Somalia", "SO", "SOM", "706"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("South Africa", "ZA", "ZAF", "710"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("South Georgia and
the South Sandwich Islands", "GS", "SGS", "239"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Spain", "ES", "ESP", "724"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Sri Lanka", "LK", "LKA",
"144"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Sudan",
"SD", "SDN", "736"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Suriname", "SR", "SUR", "740"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Svalbard and Jan Mayen", "SJ", "SJM", "744"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Swaziland", "SZ", "SWZ",
"748"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Sweden",
"SE", "SWE", "752"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Switzerland", "CH", "CHE", "756"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Syrian Arab Republic", "SY", "SYR", "760"); INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Taiwan, Province
of China", "TW", "TWN", "158"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Tajikistan", "TJ", "TJK", "762"); INSERT INTO country (name,
code_alpha_2, code_alpha_3, code_numeric) VALUES("Tanzania, United Republic of", "TZ",
"TZA", "834"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Thailand", "TH", "THA", "764"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Timor-Leste", "TL", "TLS", "626"); INSERT INTO country (name,
code_alpha_2, code_alpha_3, code_numeric) VALUES("Togo", "TG", "TGO", "768"); INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Tokelau", "TK",
"TKL", "772"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Tonga", "TO", "TON", "776"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Trinidad and Tobago", "TT", "TTO", "780"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Tunisia", "TN", "TUN", "788");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Turkey",
"TR", "TUR", "792"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Turkmenistan", "TM", "TKM", "795"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Turks and Caicos Islands", "TC", "TCA", "796");
INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Tuvalu",
"TV", "TUV", "798"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Uganda", "UG", "UGA", "800"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Ukraine", "UA", "UKR", "804"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("United Arab Emirates", "AE", "ARE", "784"); INSERT
INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("United Kingdom",
"GB", "GBR", "826"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("United States", "US", "USA", "840"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("United States Minor Outlying Islands", "UM", "UMI",
"581"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Uruguay",
"UY", "URY", "858"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Uzbekistan", "UZ", "UZB", "860"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Vanuatu", "VU", "VUT", "548"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Venezuela, Bolivarian Republic
of", "VE", "VEN", "862"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Viet Nam", "VN", "VNM", "704"); INSERT INTO country (name, code_alpha_2, code_alpha_3,
code_numeric) VALUES("Virgin Islands, British", "VG", "VGB", "092"); INSERT INTO country
(name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Virgin Islands, U.S.", "VI",
"VIR", "850"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Wallis and Futuna", "WF", "WLF", "876"); INSERT INTO country (name, code_alpha_2,
code_alpha_3, code_numeric) VALUES("Western Sahara", "EH", "ESH", "732"); INSERT INTO
country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Yemen", "YE", "YEM",
"887"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric) VALUES("Zambia",
"ZM", "ZMB", "894"); INSERT INTO country (name, code_alpha_2, code_alpha_3, code_numeric)
VALUES("Zimbabwe", "ZW", "ZWE", "716"); &lt;/textarea&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.fluxtah.com/aggbug.ashx?id=5f1a8d18-251a-49d2-9619-fb34b1ab8892" /&gt;</description>
      <comments>http://www.fluxtah.com/CommentView,guid,5f1a8d18-251a-49d2-9619-fb34b1ab8892.aspx</comments>
      <category>Javascript</category>
      <category>SQL</category>
    </item>
    <item>
      <trackback:ping>http://www.fluxtah.com/Trackback.aspx?guid=5a3e7a2a-4ccf-4f12-bd1a-8b9a21e0c7ab</trackback:ping>
      <pingback:server>http://www.fluxtah.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.fluxtah.com/PermaLink,guid,5a3e7a2a-4ccf-4f12-bd1a-8b9a21e0c7ab.aspx</pingback:target>
      <dc:creator>Fluxtah</dc:creator>
      <wfw:commentRss>http://www.fluxtah.com/SyndicationService.asmx/GetEntryCommentsRss?guid=5a3e7a2a-4ccf-4f12-bd1a-8b9a21e0c7ab</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Whilst working on my network engine I came across a problem that I initially solved
with an interface, but it turned out that the class that implemented this interface
exposed public methods that I really wanted to be private, an example will explain
the problem. 
</p>
        <pre>
          <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px">
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span>
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">interface</span> IMessageReceiver
{ <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">void</span> Receive(<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">string</span> message);
} <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">interface</span> IMessageProvider
{ IMessageReceiver MessageReceiver; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">void</span> Update();
} <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">class</span> ConcreteReceiver:
IMessageReceiver { <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">private</span> IMessageProvider
_MessageProvider; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span> ConcreteReciever(IMessageProvider
messageProvider) { _MessageProvider <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> messageProvider;
_MessageProvider.MessageReceiver <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">this</span>;
} <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">void</span> Receive(<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">string</span> message)
{ Console.WriteLine(message); } <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">void</span> Update()
{ MessageProvider.Update(); } } </span>
        </pre>
        <p>
When calling ConcreteReceiver.Update(), this will call MessageProvider.Update(), then,
the concrete implementation of IMessageProvider should call IMessageReceiver.Receive,
effectively like a callback.<br /><br />
Now the issue in my case was that I did not want the Receive method of ConcreteReceiver
to be public, but of course any concrete type that implements an interface must implement
those methods as public, after pondering a while I realised the design was actually
flawed anyway, what I really wanted was a callback, so I changed my design as follows.
</p>
        <pre>
          <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px">
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span>
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">interface</span> IMessageProvider
{ Action&lt;<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">string</span>&gt;
ReceiveAction; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">void</span> Update();
} <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">class</span> ConcreteReceiver
{ <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">private</span> IMessageProvider
_MessageProvider; <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span> ConcreteReciever(IMessageProvider
messageProvider) { _MessageProvider <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> messageProvider;
_MessageProvider.ReceiveAction <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> Receive;
} <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">private</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">void</span> Receive(<span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">string</span> message)
{ Console.WriteLine(message); } <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">void</span> Update()
{ MessageProvider.Update(); } } </span>
        </pre>
        <p>
So now my Receive method on my ConcreteReceiver can be private, since I am now using
a generic Action&lt;T&gt; delegate, this prevents my public API exposing methods that
are really meant to be only used internally. 
</p>
        <img width="0" height="0" src="http://www.fluxtah.com/aggbug.ashx?id=5a3e7a2a-4ccf-4f12-bd1a-8b9a21e0c7ab" />
      </body>
      <title>Interface or Delegate?</title>
      <guid isPermaLink="false">http://www.fluxtah.com/PermaLink,guid,5a3e7a2a-4ccf-4f12-bd1a-8b9a21e0c7ab.aspx</guid>
      <link>http://www.fluxtah.com/2009/09/15/InterfaceOrDelegate.aspx</link>
      <pubDate>Tue, 15 Sep 2009 02:50:00 GMT</pubDate>
      <description>&lt;p&gt;
Whilst working on my network engine I came across a problem that I initially solved
with an interface, but it turned out that the class that implemented this interface
exposed public methods that I really wanted to be private, an example will explain
the problem. 
&lt;/p&gt;
&lt;pre&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;interface&lt;/span&gt; IMessageReceiver
{ &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;void&lt;/span&gt; Receive(&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;string&lt;/span&gt; message);
} &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;interface&lt;/span&gt; IMessageProvider
{ IMessageReceiver MessageReceiver; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;void&lt;/span&gt; Update();
} &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;class&lt;/span&gt; ConcreteReceiver:
IMessageReceiver { &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;private&lt;/span&gt; IMessageProvider
_MessageProvider; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; ConcreteReciever(IMessageProvider
messageProvider) { _MessageProvider &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; messageProvider;
_MessageProvider.MessageReceiver &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;this&lt;/span&gt;;
} &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;void&lt;/span&gt; Receive(&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;string&lt;/span&gt; message)
{ Console.WriteLine(message); } &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;void&lt;/span&gt; Update()
{ MessageProvider.Update(); } } &lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
When calling ConcreteReceiver.Update(), this will call MessageProvider.Update(), then,
the concrete implementation of IMessageProvider should call IMessageReceiver.Receive,
effectively like a callback.&lt;br&gt;
&lt;br&gt;
Now the issue in my case was that I did not want the Receive method of ConcreteReceiver
to be public, but of course any concrete type that implements an interface must implement
those methods as public, after pondering a while I realised the design was actually
flawed anyway, what I really wanted was a callback, so I changed my design as follows.
&lt;/p&gt;
&lt;pre&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;interface&lt;/span&gt; IMessageProvider
{ Action&amp;lt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;string&lt;/span&gt;&amp;gt;
ReceiveAction; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;void&lt;/span&gt; Update();
} &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;class&lt;/span&gt; ConcreteReceiver
{ &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;private&lt;/span&gt; IMessageProvider
_MessageProvider; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; ConcreteReciever(IMessageProvider
messageProvider) { _MessageProvider &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; messageProvider;
_MessageProvider.ReceiveAction &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; Receive;
} &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;private&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;void&lt;/span&gt; Receive(&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;string&lt;/span&gt; message)
{ Console.WriteLine(message); } &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;void&lt;/span&gt; Update()
{ MessageProvider.Update(); } } &lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
So now my Receive method on my ConcreteReceiver can be private, since I am now using
a generic Action&amp;lt;T&amp;gt; delegate, this prevents my public API exposing methods that
are really meant to be only used internally. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.fluxtah.com/aggbug.ashx?id=5a3e7a2a-4ccf-4f12-bd1a-8b9a21e0c7ab" /&gt;</description>
      <comments>http://www.fluxtah.com/CommentView,guid,5a3e7a2a-4ccf-4f12-bd1a-8b9a21e0c7ab.aspx</comments>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://www.fluxtah.com/Trackback.aspx?guid=39d8048b-31ee-4d9f-aae6-65648c0a75bc</trackback:ping>
      <pingback:server>http://www.fluxtah.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.fluxtah.com/PermaLink,guid,39d8048b-31ee-4d9f-aae6-65648c0a75bc.aspx</pingback:target>
      <dc:creator>Fluxtah</dc:creator>
      <wfw:comment>http://www.fluxtah.com/CommentView,guid,39d8048b-31ee-4d9f-aae6-65648c0a75bc.aspx</wfw:comment>
      <wfw:commentRss>http://www.fluxtah.com/SyndicationService.asmx/GetEntryCommentsRss?guid=39d8048b-31ee-4d9f-aae6-65648c0a75bc</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The Available property of the System.Net.Sockets class will tell you how much data
is available to read. 
</p>
        <p>
With UDP sockets, one thing to remember is that Socket.Available will give the total
size of all the datagrams ready to read, so to the only way to know how many datagrams
are waiting to be read is to call ReceiveFrom repeatedly until all data is read, for
instance:- 
</p>
        <pre>
          <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px">
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">while</span>(Socket.Available
&gt; 0) { <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">int</span> datagramSize <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> Socket.ReceiveFrom(buffer, <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">ref</span> endPoint);
} </span>
        </pre>
        <p>
          <font face="verdana,geneva">The datagramSize variable will give the size of the datagram
that was read, this can be troublesome to manage since you do not know what you are
going to get, until you get it, so you would need to initialize a large enough buffer
to hold the datagram.</font>
        </p>
        <p>
In the networking framework I am currently writing, the application has a configurable
MaxPacketSize option so I can initialize my buffer to this size, but this wont help
in the event that a bum packet is sent that breaches this constraint so some error
handling would also need to be in place to compensate for this issue. 
</p>
        <p>
        </p>
        <img width="0" height="0" src="http://www.fluxtah.com/aggbug.ashx?id=39d8048b-31ee-4d9f-aae6-65648c0a75bc" />
      </body>
      <title>Socket.Available and UDP</title>
      <guid isPermaLink="false">http://www.fluxtah.com/PermaLink,guid,39d8048b-31ee-4d9f-aae6-65648c0a75bc.aspx</guid>
      <link>http://www.fluxtah.com/2009/09/09/SocketAvailableAndUDP.aspx</link>
      <pubDate>Wed, 09 Sep 2009 16:26:00 GMT</pubDate>
      <description>&lt;p&gt;
The Available property of the System.Net.Sockets class will tell you how much data
is available to read. 
&lt;/p&gt;
&lt;p&gt;
With UDP sockets, one thing to remember is that Socket.Available will give the total
size of all the datagrams ready to read, so to the only way to know how many datagrams
are waiting to be read is to call ReceiveFrom repeatedly until all data is read, for
instance:- 
&lt;/p&gt;
&lt;pre&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;while&lt;/span&gt;(Socket.Available
&amp;gt; 0) { &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;int&lt;/span&gt; datagramSize &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; Socket.ReceiveFrom(buffer, &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;ref&lt;/span&gt; endPoint);
} &lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font face=verdana,geneva&gt;The datagramSize variable will give the size of the datagram
that was read, this can be troublesome to manage since you do not know what you are
going to get, until you get it, so you would need to initialize a large enough buffer
to hold the datagram.&lt;/font&gt; 
&lt;/p&gt;
&lt;p&gt;
In the networking framework I am currently writing, the application has a configurable
MaxPacketSize option so I can initialize my buffer to this size, but this wont help
in the event that a bum packet is sent that breaches this constraint so some error
handling would also need to be in place to compensate for this issue. 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.fluxtah.com/aggbug.ashx?id=39d8048b-31ee-4d9f-aae6-65648c0a75bc" /&gt;</description>
      <comments>http://www.fluxtah.com/CommentView,guid,39d8048b-31ee-4d9f-aae6-65648c0a75bc.aspx</comments>
      <category>C#</category>
    </item>
  </channel>
</rss>