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

<channel>
	<title>Conroy Software Snippets</title>
	<atom:link href="http://www.conroys.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.conroys.co.uk</link>
	<description>ASP.NET AJAX SQL JQUERY</description>
	<lastBuildDate>Thu, 21 Apr 2011 08:37:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Reset SQL Identity Seed Using Identity Increment</title>
		<link>http://www.conroys.co.uk/2011/04/21/reset-sql-identity-seed-using-identity-increment/</link>
		<comments>http://www.conroys.co.uk/2011/04/21/reset-sql-identity-seed-using-identity-increment/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 08:34:56 +0000</pubDate>
		<dc:creator>Conners</dc:creator>
				<category><![CDATA[MS SQL]]></category>
		<category><![CDATA[identity increment]]></category>
		<category><![CDATA[identity seed]]></category>
		<category><![CDATA[increment value]]></category>
		<category><![CDATA[ms sql]]></category>
		<category><![CDATA[primary key]]></category>
		<category><![CDATA[reseed]]></category>
		<category><![CDATA[reset identity]]></category>
		<category><![CDATA[seed value]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.conroys.co.uk/?p=23</guid>
		<description><![CDATA[Reset SQL Identity Seed Using Identity Increment Back To 1 within Identity Specification To reset the Identity Seed in MS SQL do the following within Microsoft SQL Server Management Studio: 1) Right Click the database that contains your table identity to reset 2) Click New Query 3) Within the query window enter the following line [...]]]></description>
			<content:encoded><![CDATA[<p>Reset SQL Identity Seed Using Identity Increment Back To 1 within Identity Specification</p>
<p>To reset the Identity Seed in MS SQL do the following within Microsoft SQL Server Management Studio:</p>
<p>1) Right Click the database that contains your table identity to reset</p>
<p>2) Click New Query</p>
<p>3) Within the query window enter the following line</p>
<p><strong>DBCC CHECKIDENT(TableToReseed,RESEED,0)</strong></p>
<p>4) Right click the query window</p>
<p>5) Click Execute</p>
<p>That&#8217;s all there is to it. I normally use this after testing to reset the database for live production.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.conroys.co.uk/2011/04/21/reset-sql-identity-seed-using-identity-increment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The specified DSN contains an architecture mismatch between the Driver and Application</title>
		<link>http://www.conroys.co.uk/2011/04/12/the-specified-dsn-contains-an-architecture-mismatch-between-the-driver-and-application/</link>
		<comments>http://www.conroys.co.uk/2011/04/12/the-specified-dsn-contains-an-architecture-mismatch-between-the-driver-and-application/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 11:29:03 +0000</pubDate>
		<dc:creator>Conners</dc:creator>
				<category><![CDATA[IIS7]]></category>
		<category><![CDATA[Internet Information Services]]></category>
		<category><![CDATA[32-bit]]></category>
		<category><![CDATA[64-bit]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[driver]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[odbc]]></category>
		<category><![CDATA[patch]]></category>

		<guid isPermaLink="false">http://www.conroys.co.uk/?p=16</guid>
		<description><![CDATA[﻿ The specified DSN contains an architecture mismatch between the Driver and Application I was transferring our company websites from IIS6 to IIS7 servers today and came up against this DSN mismatch problem. (From IIS7) System.Data.Odbc.OdbcException: ERROR [IM014] [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application To cut [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" class="mcePaste" style="position: absolute; width: 1px; height: 1px; overflow: hidden; top: 0px; left: -10000px;">﻿</div>
<p>The specified DSN contains an architecture mismatch between the Driver and Application</p>
<p>I was transferring our company websites from IIS6 to IIS7 servers today and came up against this DSN mismatch problem.</p>
<p>(From IIS7)</p>
<p><strong>System.Data.Odbc.OdbcException: ERROR [IM014] [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application</strong></p>
<p>To cut a long story short, the IIS7 website was looking for a 64 bit DSN version of the requested driver. The required 64 bit driver was Pervasive ODBC (of which we only had a 32 bit driver!)</p>
<p>My company was not going to pay to upgrade from a 32 bit to 64 bit driver. Therefore, simply setting up a 64 bit dsn was a non starter.</p>
<p>I had to make the website in IIS7 a 32 bit application to read the working 32 bit Pervasive ODBC driver already installed!</p>
<p><strong>How to correct the problem (all in IIS7):</strong></p>
<p>1) Create a new application pool</p>
<p>2) Name it 32BitWeb</p>
<p>3) Use the .NET Framework v2.0.50727</p>
<p>4) Pipeline Mode Classic</p>
<p>5) Enable 32-Bit Applications TRUE</p>
<p>6) Identity Network Service</p>
<p>7) Load User Profile False</p>
<p>8) Attach your website to Application Pool 32BitWeb</p>
<p><strong>MOST IMPORTANTLY</strong></p>
<p>9) Go into Handler Mappings and open up (Inherited) AboMapperCustom-5548907</p>
<p>10) Change the Executable address from:</p>
<p>C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll</p>
<p>to</p>
<p>C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll</p>
<p>11) Click &#8216;Yes&#8217; to Edit Wildcard Script Map</p>
<p>That&#8217;s all there is to it. I simply told the website handler mappings to use 32bit drivers instead of 64bit.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.conroys.co.uk/2011/04/12/the-specified-dsn-contains-an-architecture-mismatch-between-the-driver-and-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to find an existing control within a masterpage or webpage in asp.net</title>
		<link>http://www.conroys.co.uk/2011/04/04/how-to-find-an-existing-control-within-a-masterpage-or-webpage-in-asp-net/</link>
		<comments>http://www.conroys.co.uk/2011/04/04/how-to-find-an-existing-control-within-a-masterpage-or-webpage-in-asp-net/#comments</comments>
		<pubDate>Mon, 04 Apr 2011 12:51:35 +0000</pubDate>
		<dc:creator>Conners</dc:creator>
				<category><![CDATA[ASP.NET C#]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[find control]]></category>
		<category><![CDATA[masterpage]]></category>
		<category><![CDATA[recursive]]></category>

		<guid isPermaLink="false">http://www.conroys.co.uk/?p=10</guid>
		<description><![CDATA[One of the first challenges I ever encountered with asp.net was the ability to find an existing control within a webpage, For example, how would I find a label, text box, panel etc. Default.aspx  &#60;html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221; &#62;   &#60;head runat=&#8221;server&#8221;&#62;       &#60;title&#62;Find Label Control&#60;/title&#62;   &#60;/head&#62;  &#60;body&#62;       &#60;form id=&#8221;form1&#8243; runat=&#8221;server&#8221;&#62;        &#60;div&#62;          &#60;asp:Label ID=&#8221;lblTest&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>One of the first challenges I ever encountered with asp.net was the ability to find an existing control within a webpage, For example, how would I find a label, text box, panel etc.</p>
<p><strong>Default.aspx</strong></p>
<p> &lt;html xmlns=&#8221;<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>&#8221; &gt;<br />
  &lt;head runat=&#8221;server&#8221;&gt;<br />
      &lt;title&gt;Find Label Control&lt;/title&gt;<br />
  &lt;/head&gt;<br />
 &lt;body&gt;<br />
      &lt;form id=&#8221;form1&#8243; runat=&#8221;server&#8221;&gt;<br />
       &lt;div&gt;<br />
 <br />
       &lt;asp:Label ID=&#8221;lblTest&#8221; runat=&#8221;server&#8221; Text=&#8221;Before&#8221; /&gt;&lt;br /&gt;&lt;br /&gt;<br />
   <br />
       &lt;asp:Button ID=&#8221;btnTest&#8221; runat=&#8221;server&#8221; Text=&#8221;Test&#8221; onclick=&#8221;btnTest_Click&#8221; /&gt;<br />
   <br />
       &lt;/div&gt;<br />
      &lt;/form&gt;<br />
 &lt;/body&gt;<br />
 &lt;/html&gt;</p>
<p><strong>Code Behind</strong></p>
<p> protected void btnTest_Click(object sender, EventArgs e)<br />
 {<br />
      lblTest.Text = &#8220;After&#8221;;<br />
 }</p>
<p>This works perfect, but what if we wanted to find a label in the masterpage?</p>
<p>The answer is as follows&#8230;</p>
<p><strong>Site.Master</strong></p>
<p> &lt;html xmlns=&#8221;<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>&#8221; &gt;<br />
 &lt;head runat=&#8221;server&#8221;&gt;<br />
      &lt;title&gt;Find Label Control Recursively&lt;/title&gt;<br />
       &lt;asp:ContentPlaceHolder ID=&#8221;head&#8221; runat=&#8221;server&#8221;&gt;<br />
       &lt;/asp:ContentPlaceHolder&gt;<br />
 &lt;/head&gt;<br />
 &lt;body&gt;<br />
      &lt;form id=&#8221;form1&#8243; runat=&#8221;server&#8221;&gt;<br />
      &lt;div&gt;<br />
   <br />
      &lt;asp:Label ID=&#8221;test2&#8243; runat=&#8221;server&#8221; Text=&#8221;Morning&#8221; /&gt;<br />
   <br />
          &lt;asp:ContentPlaceHolder ID=&#8221;ContentPlaceHolder1&#8243; runat=&#8221;server&#8221;&gt;<br />
       <br />
          &lt;/asp:ContentPlaceHolder&gt;<br />
      &lt;/div&gt;<br />
      &lt;/form&gt;<br />
 &lt;/body&gt;<br />
 &lt;/html&gt;</p>
<p><strong>WebForm1.aspx.cs</strong><br />
 protected void Page_Load(object sender, EventArgs e)<br />
        {<br />
            /* Will Get Error if using masterpage<br />
            Label myLabel = (Label)FindControl(&#8220;test2&#8243;);<br />
            myLabel.Text = &#8220;Evening&#8221;;<br />
             */</p>
<p>     // This will work!<br />
            Label myLabel2 = (Label)FindControlRecursive(&#8220;test2&#8243;);<br />
            myLabel2.Text = &#8220;Evening&#8221;;<br />
        }</p>
<p>        protected virtual Control FindControlRecursive(string id)<br />
        {<br />
            return FindControlRecursive(id, this);<br />
        }</p>
<p>        protected virtual Control FindControlRecursive(string id, Control parent)<br />
        {</p>
<p>            // If parent is the control we&#8217;re looking for, return it</p>
<p>            if (string.Compare(parent.ID, id, true) == 0)</p>
<p>                return parent;</p>
<p>            // Search through children</p>
<p>            foreach (Control child in parent.Controls)<br />
            {</p>
<p>                Control match = FindControlRecursive(id, child);</p>
<p>                if (match != null)</p>
<p>                    return match;</p>
<p>            }</p>
<p>            // If we reach here then no control with id was found</p>
<p>            return null;<br />
        }</p>
<p>On running the webpage WebForm1.aspx, the label id &#8216;test2&#8242; text within the masterpage will show as &#8216;Evening&#8217;.</p>
<p>It&#8217;s as simple as that! You can find any control using the FindControlRecursive method above including text boxes, labels, panels etc.</p>
<p><span style="color: #ff0000;"><strong>ADVANCED</strong></span></p>
<p>If you wish to reuse the coding in several pages and don&#8217;t want to repeat the code, then enter the code in your custom BasePage class within the App_Data Folder.</p>
<p><strong><span style="color: #000000;">WebForm2.aspx.cs</span></strong></p>
<p>    public partial class WebForm2 : BasePage<br />
    {<br />
        protected void Page_Load(object sender, EventArgs e)<br />
        {<br />
            Label l = (Label)FindControlRecursive(&#8220;test2&#8243;);<br />
            l.Text = &#8220;I love asp.net!&#8221;;<br />
        }<br />
    }</p>
<p><strong>BasePage.cs </strong>(within App_Data folder)</p>
<p>using System.Web.UI; // don&#8217;t forget to add this namespace!</p>
<p>    public class BasePage : System.Web.UI.Page<br />
    {<br />
       <br />
        protected virtual Control FindControlRecursive(string id)<br />
        {<br />
            return FindControlRecursive(id, this);<br />
        }<br />
       <br />
        protected virtual Control FindControlRecursive(string id, Control parent)<br />
        {<br />
            // If parent is the control we&#8217;re looking for, return it</p>
<p>            if (string.Compare(parent.ID, id, true) == 0)</p>
<p>                return parent;</p>
<p>            // Search through children</p>
<p>            foreach (Control child in parent.Controls)<br />
            {</p>
<p>                Control match = FindControlRecursive(id, child);</p>
<p>                if (match != null)</p>
<p>                    return match;</p>
<p>            }</p>
<p>            // If we reach here then no control with id was found</p>
<p>            return null;<br />
        }<br />
    }</p>
<p>Thats all there is to it! If you need any further help on this topic, please leave a comment or email me direct thorugh this site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.conroys.co.uk/2011/04/04/how-to-find-an-existing-control-within-a-masterpage-or-webpage-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

