<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-11186733</id><updated>2024-10-25T02:02:36.924-04:00</updated><title type='text'>_DotNetStuff and more...</title><subtitle type='html'>.NET, C#, ASP.NET</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>19</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-11186733.post-6515932038887906200</id><published>2009-01-21T12:21:00.000-05:00</published><updated>2009-01-21T12:22:12.603-05:00</updated><title type='text'>I have recently moved to WordPress, see you there...</title><content type='html'>&lt;a href=&quot;http://cooldotnetstuff.wordpress.com/&quot;&gt;http://cooldotnetstuff.wordpress.com/&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/6515932038887906200/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/6515932038887906200' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/6515932038887906200'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/6515932038887906200'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2009/01/i-have-recently-moved-to-wordpress-see.html' title='I have recently moved to WordPress, see you there...'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11186733.post-8328925227808806234</id><published>2009-01-20T13:27:00.002-05:00</published><updated>2009-01-20T13:33:01.080-05:00</updated><title type='text'>SQL Server 2008 and PowerShell</title><content type='html'>SQL Server 2008 now has support for &lt;a href=&quot;http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx&quot;&gt;PowerShell&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;SQL Server provides two &lt;a href=&quot;http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx&quot;&gt;PowerShell&lt;/a&gt; snap-ins that implement:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;    A SQL Server provider, which enables a simple navigation mechanism similar to file system paths. You can build paths similar to file system paths, where the drive is associated with a SQL Server management object model, and the nodes are based on the object model classes. You can then use familiar commands such as cd and dir to navigate the paths similar to the way you navigate folders in a command prompt window. You can use other commands, such as ren or del, to perform actions on the nodes in the path.&lt;/li&gt;&lt;li&gt;    A set of cmdlets, which are commands used in PowerShell scripts to specify a SQL Server action. The SQL Server cmdlets support actions such as running a sqlcmd script containing Transact-SQL or XQuery statements.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Resources&lt;/span&gt;:&lt;br /&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/cc281954.aspx&quot;&gt;SQL Server PowerShell Overview&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://powershell.com/cs/media/g/sql-server/default.aspx&quot;&gt;Pre-written Powershell scripts for SQL Server Management&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/8328925227808806234/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/8328925227808806234' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/8328925227808806234'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/8328925227808806234'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2009/01/sql-server-2008-and-powershell.html' title='SQL Server 2008 and PowerShell'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11186733.post-6911476165003617145</id><published>2009-01-16T14:03:00.004-05:00</published><updated>2009-01-16T21:33:34.933-05:00</updated><title type='text'>SQL Server Standard Edition 2005 upgrade to SQL Server Standard 2008 upgrade rules fail</title><content type='html'>I had an issue with SQL Server 2008 Upgrade Rules.  I was running SQL Server 2005 Standard.  I could not get past the Upgrade Rules.  I told me I was trying to upgrade to an incompatible version and to see the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms143393.aspx&quot;&gt;version matrix&lt;/a&gt;.  It made no sense to me. I ran &quot;Select @@version&quot; and it all came back correct.  I did some digging into the Microsoft SQL Server\100\Setup Bootstrap\Log\Summary.txt.  I found out that my Reporting Services and tools version were installed with SQL Server 2005 Developer Edition.  &lt;br /&gt;&lt;br /&gt;What! How could that be?  Yes, that is what I had installed, so not matter what version I tried to upgrade to it failed.  The installer could not figure out what to do.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;The Solution&lt;/span&gt;:&lt;br /&gt;None really, I could not upgrade.&lt;br /&gt;So, I had to re-create my environment with a new clean install of SQL Server 2005 Standard w/ Reporting Services then go through my upgrade tests.  All was fine after that.</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/6911476165003617145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/6911476165003617145' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/6911476165003617145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/6911476165003617145'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2009/01/sql-server-standard-edition-2005.html' title='SQL Server Standard Edition 2005 upgrade to SQL Server Standard 2008 upgrade rules fail'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11186733.post-351536084550111</id><published>2009-01-16T13:52:00.004-05:00</published><updated>2009-01-16T21:35:07.941-05:00</updated><title type='text'>Upgrade to SQL Server 2008 fixes Reporting Services nested data region export to Excel</title><content type='html'>I recently upgraded to &lt;a href=&quot;http://www.microsoft.com/sqlserver/2008/en/us/overview.aspx&quot;&gt;SQL Server 2008&lt;/a&gt;.  The primary reason was to fix an issue with &lt;a href=&quot;http://technet.microsoft.com/en-us/library/ms155976(SQL.90).aspx&quot;&gt;SQL Server Reporting Services - Excel Export issues with nested data regions&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&quot;Any data region nested inside of a table or matrix data region is not supported. An error is displayed in Excel if this layout is encountered.&quot;&lt;br /&gt;&lt;br /&gt;They reportedly fixed this issue in SQL Server 2008.  I my testing supports the claim and we no longer have the &lt;a href=&quot;http://technet.microsoft.com/en-us/library/ms155976(SQL.90).aspx&quot;&gt;&quot;nested data region errors&quot;&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I must say that I was impressed with the new installer.  Microsoft goes to great lengths to validate your SQL Server configuration before trying to upgrade.  I had one upgrade issue that &lt;a href=&quot;http://cooldotnetstuff.blogspot.com/2009/01/sql-server-standard-edition-2005.html&quot;&gt;I talk about in this post, that was caused by me&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/351536084550111/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/351536084550111' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/351536084550111'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/351536084550111'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2009/01/upgrade-from-sql-server-2005-to-sql.html' title='Upgrade to SQL Server 2008 fixes Reporting Services nested data region export to Excel'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11186733.post-8551961500910230241</id><published>2008-10-28T09:58:00.001-04:00</published><updated>2008-10-28T10:00:47.447-04:00</updated><title type='text'>How does Response.Redirect in ASP.NET implement HTTP 302</title><content type='html'>&lt;pre class=&quot;libCScode&quot; id=&quot;ctl00_rs1_mainContentContainer_ctl18other&quot; space=&quot;preserve&quot;&gt;HTTP 1.0 302 Object Moved&lt;br /&gt;Location &lt;br /&gt;http://www.microsoft.com&lt;br /&gt;&lt;/pre&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms524309.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/ms524309.aspx&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/8551961500910230241/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/8551961500910230241' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/8551961500910230241'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/8551961500910230241'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2008/10/how-does-responseredirect-in-aspnet.html' title='How does Response.Redirect in ASP.NET implement HTTP 302'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11186733.post-6732746921053110866</id><published>2008-10-28T09:22:00.002-04:00</published><updated>2008-10-28T09:57:32.639-04:00</updated><title type='text'>Validate .NET control and javascript confim before postback</title><content type='html'>&lt; &lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;asp&lt;/span&gt;:&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;imagebutton&lt;/span&gt; id=&lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;&quot;ibDelete&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 102, 102);&quot;&gt;causesvalidation&lt;/span&gt;=&lt;span style=&quot;color: rgb(102, 102, 204);&quot;&gt;&quot;true&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;onclientclick&lt;/span&gt;=&lt;span style=&quot;color: rgb(102, 102, 204);&quot;&gt;&quot;return checkDelete()&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 102, 102);&quot;&gt;validationgroup&lt;/span&gt;=&lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;&quot;ModalValidation&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 102, 102);&quot;&gt;alternatetext&lt;/span&gt;=&lt;span style=&quot;color: rgb(102, 102, 204);&quot;&gt;&quot;Delete Journal&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;runat&lt;/span&gt;=&lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;&quot;server&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;imageurl&lt;/span&gt;=&lt;span style=&quot;color: rgb(102, 102, 204);&quot;&gt;&quot;~/images/icons/delete.gif&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 102, 102);&quot;&gt;onclick&lt;/span&gt;=&lt;span style=&quot;color: rgb(102, 102, 204);&quot;&gt;&quot;ibDelete_Click&quot;&lt;/span&gt;/&gt;&lt;br /&gt;&lt;br /&gt;function checkDelete(){&lt;br /&gt;           if(Page_ClientValidate())&lt;br /&gt;           {&lt;br /&gt;                    var record=confirm(&#39;Are you sure you want to delete this record?&#39;);&lt;br /&gt;                    if(record == 1)&lt;br /&gt;                    {            &lt;br /&gt;                             return true;&lt;br /&gt;                    }&lt;br /&gt;                    else if(record == 0)&lt;br /&gt;                    {                         &lt;br /&gt;                             return false;&lt;br /&gt;                   }&lt;br /&gt;     }&lt;br /&gt; }</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/6732746921053110866/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/6732746921053110866' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/6732746921053110866'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/6732746921053110866'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2008/10/validate-net-control-and-javascript.html' title='Validate .NET control and javascript confim before postback'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11186733.post-5447325677326326833</id><published>2008-09-19T09:44:00.002-04:00</published><updated>2008-09-19T09:55:07.714-04:00</updated><title type='text'>Manually calling ASP.NET Validation with JavaScript</title><content type='html'>I put a version of this function on the OnClientClick event of a ASP.NET button control. &lt;br /&gt;&lt;br /&gt;The requirement I had was to find out how many validation controls fired, show a modal dialog and then set focus to the first Invliad Validator control. I left the modal dialog code out of this example as there are plenty of good resources on the web.&lt;br /&gt;&lt;br /&gt;Page_ClientValidate() will force validation on the client side. &lt;br /&gt;&lt;br /&gt;Page_Validators is a collection of Validation controls on the page in which you can access and evaluate however you see fit. &lt;br /&gt;&lt;br /&gt;The ValidatorFocus() function is for my solution is called when my modal closes. &lt;br /&gt;&lt;br /&gt;        function ValidationCatcher()&lt;br /&gt;        {&lt;br /&gt;            //force .net validation&lt;br /&gt;            Page_ClientValidate();           &lt;br /&gt;                       &lt;br /&gt;            var count = 0;&lt;br /&gt;            for(i=0; i &lt; Page_Validators.length; i++){&lt;br /&gt;               if(!Page_Validators[i].isvalid)&lt;br /&gt;               {&lt;br /&gt;                    count = count+1;                   &lt;br /&gt;               }&lt;br /&gt;            }&lt;br /&gt;            //set msg for dialog message&lt;br /&gt;            alert(count); &lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        function ValidatorFocus()&lt;br /&gt;        {           &lt;br /&gt;            var i;&lt;br /&gt;            for (i = 0; i &lt; Page_Validators.length; i++) {&lt;br /&gt;                if (!Page_Validators[i].isvalid) {&lt;br /&gt;                    document.getElementById(&lt;br /&gt;                    Page_Validators[i].controltovalidate).focus();&lt;br /&gt;                    break;&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;A few resources that I came across:&lt;br /&gt;&lt;a href=&quot;http://timstall.dotnetdevelopersjournal.com/validation_tips_for_validators.htm&quot;&gt;http://timstall.dotnetdevelopersjournal.com/validation_tips_for_validators.htm&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://www.codeproject.com/KB/validation/customvalidationscripts.aspx&quot;&gt;&lt;br /&gt;http://www.codeproject.com/KB/validation/customvalidationscripts.aspx&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/5447325677326326833/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/5447325677326326833' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/5447325677326326833'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/5447325677326326833'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2008/09/manually-calling-aspnet-validation-with.html' title='Manually calling ASP.NET Validation with JavaScript'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11186733.post-2568408686559593615</id><published>2008-09-09T09:05:00.004-04:00</published><updated>2008-09-09T09:32:15.833-04:00</updated><title type='text'>Logging in .NET</title><content type='html'>Options:&lt;br /&gt;&lt;a href=&quot;http://www.microsoft.com/downloads/details.aspx?FamilyId=4C557C63-708F-4280-8F0C-637481C31718&amp;amp;displaylang=en&quot;&gt;Enterprise Library 3.1&lt;/a&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Populating and raising events from code &lt;/li&gt;&lt;li&gt;Populating a log message with additional context information &lt;/li&gt;&lt;li&gt;Tracing activities and propagating context information &lt;/li&gt;&lt;li&gt;Checking filter status before constructing log messages.&lt;/li&gt;&lt;li&gt;Configuring options for trace listeners &lt;/li&gt;&lt;li&gt;Directing different event types to different trace listeners &lt;/li&gt;&lt;li&gt;Configuring log filters &lt;/li&gt;&lt;li&gt;Configure logging to be performed from a central location&lt;/li&gt;&lt;li&gt;Creating a custom trace listener&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a href=&quot;http://logging.apache.org/log4net/download.html&quot;&gt;log4net 1.2.10&lt;/a&gt;&lt;br /&gt;log4net is a tool to help the programmer output log statements to a                      variety of output targets. In case of problems with an application,                      it is helpful to enable logging so that the problem can be located.                      With log4net it is possible to enable logging at runtime without                      modifying the application binary. The log4net package is designed so                      that log statements can remain in shipped code without incurring a                      high performance cost. It follows that the speed of logging (or                      rather not logging) is crucial.                                  &lt;p&gt;                     At the same time, log output can be so voluminous that it quickly becomes                      overwhelming. One of the distinctive features of log4net is the notion of                      hierarchical loggers. Using these loggers it is possible to selectively                      control which log statements are output at arbitrary granularity.                  &lt;/p&gt;                 &lt;p&gt;                     log4net is designed with two distinct goals in mind: speed and flexibility                 &lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/2568408686559593615/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/2568408686559593615' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/2568408686559593615'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/2568408686559593615'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2008/09/logging-in-net.html' title='Logging in .NET'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11186733.post-2826049615246840054</id><published>2008-08-21T12:56:00.002-04:00</published><updated>2008-08-21T12:59:23.957-04:00</updated><title type='text'>Universal Extractor, a must have tool</title><content type='html'>&lt;a href=&quot;http://legroom.net/software/uniextract&quot;&gt;http://legroom.net/software/uniextract&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://legroom.net/files/software/uniextract_gui.png&quot;&gt;&lt;img style=&quot;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px;&quot; src=&quot;http://legroom.net/files/software/uniextract_gui.png&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://legroom.net/files/software/uniextract_context.png&quot;&gt;&lt;img style=&quot;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px;&quot; src=&quot;http://legroom.net/files/software/uniextract_context.png&quot; alt=&quot;&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/2826049615246840054/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/2826049615246840054' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/2826049615246840054'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/2826049615246840054'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2008/08/universal-extractor-must-have-tool.html' title='Universal Extractor, a must have tool'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11186733.post-2313974371939577946</id><published>2008-08-14T14:23:00.003-04:00</published><updated>2008-08-14T14:33:45.452-04:00</updated><title type='text'>Web page debuggers I can&#39;t live without!</title><content type='html'>&lt;a href=&quot;http://getfirebug.com/&quot;&gt;Firebug&lt;/a&gt;&lt;a href=&quot;http://getfirebug.com/&quot;&gt; &lt;/a&gt;for Firefox:&lt;br /&gt;&lt;br /&gt;You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://getfirebug.com/&quot;&gt;&lt;img class=&quot;yoono-image&quot; style=&quot;border: 0pt none ; width: 507px; height: 230px;&quot; src=&quot;http://getfirebug.com/html1.gif&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.microsoft.com/downloads/details.aspx?FamilyId=E59C3964-672D-4511-BB3E-2D5E1DB91038&amp;amp;displaylang=en&quot;&gt;Internet Developer Toolbar&lt;/a&gt; for IE:&lt;br /&gt;&lt;span&gt;&lt;ul&gt;&lt;li&gt;Explore and modify the document object model (DOM) of a Web page.&lt;/li&gt;&lt;li&gt;Locate and select specific elements on a Web page through a variety of techniques.&lt;/li&gt;&lt;li&gt;Selectively disable Internet Explorer settings.&lt;/li&gt;&lt;li&gt;View HTML object class names, ID&#39;s, and details such as link paths, tab index values, and access keys.&lt;/li&gt;&lt;li&gt;Outline tables, table cells, images, or selected tags.&lt;/li&gt;&lt;li&gt;Validate HTML, CSS, WAI, and RSS web feed links.&lt;/li&gt;&lt;li&gt;Display image dimensions, file sizes, path information, and alternate (ALT) text.&lt;/li&gt;&lt;li&gt;Immediately resize the browser window to a new resolution.&lt;/li&gt;&lt;li&gt;Selectively clear the browser cache and saved cookies. Choose from all objects or those associated with a given domain.&lt;/li&gt;&lt;li&gt;Display a fully featured design ruler to help accurately align and measure objects on your pages.&lt;/li&gt;&lt;li&gt;Find the style rules used to set specific style values on an element.&lt;/li&gt;&lt;li&gt;View the formatted and syntax colored source of HTML and CSS.&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/2313974371939577946/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/2313974371939577946' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/2313974371939577946'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/2313974371939577946'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2008/08/web-page-debuggers-i-cant-live-without.html' title='Web page debuggers I can&#39;t live without!'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11186733.post-6654533022190566123</id><published>2008-07-31T14:37:00.002-04:00</published><updated>2008-07-31T14:42:19.841-04:00</updated><title type='text'>Sys.WebForms.PageRequestManagerServerErrorException: 500</title><content type='html'>&lt;span style=&quot;font-weight: bold;&quot;&gt;Sys.WebForms.PageRequestManagerServerErrorException:An unknown error occured while processing the request on the server.The status code returned from the server was:500&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;The real error was:&lt;/span&gt;&lt;br /&gt;Invalid postback or callback argument.  Event validation is enabled using;&amp;lt;pages enableeventvalidation=&quot;true&quot;/&amp;gt;; in configuration or &lt;@ Page EnableEventValidation=&quot;true&quot; %/&gt;; in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;The fix for me:&lt;/span&gt;&lt;br /&gt;EnableEventValidation=&quot;false&quot;</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/6654533022190566123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/6654533022190566123' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/6654533022190566123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/6654533022190566123'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2008/07/syswebformspagerequestmanagerservererro.html' title='Sys.WebForms.PageRequestManagerServerErrorException: 500'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11186733.post-3193323990734841240</id><published>2008-07-31T00:19:00.009-04:00</published><updated>2008-07-31T08:05:56.266-04:00</updated><title type='text'>Image(img) doesn&#39;t show up on initial page load, FireFox 2.0.0.16</title><content type='html'>Here is the tag &lt;span style=&quot;font-style: italic;font-size:85%;&quot; &gt;&amp;lt;img src=&quot;images/exampleLogo.gif&quot; /&amp;gt;&lt;/span&gt;, what is wrong with it?  Well, it depends on the browser and DOCTYPE and CSS being used.  In this case I was using &lt;span style=&quot;color: rgb(51, 204, 0); font-style: italic;&quot;&gt;FireFox 2.0.0.16&lt;/span&gt; , DOCTYPE &lt;span style=&quot;color: rgb(51, 204, 0); font-style: italic;&quot;&gt;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&lt;/span&gt; and some &lt;span style=&quot;color: rgb(51, 204, 0); font-style: italic;&quot;&gt;CSS &lt;/span&gt;to center my DIV on the screen.   The result was that using the img tag without the width and height defined resulted in the image not showing up unless I refreshed the screen.  I have had this same issue with Javascript img rollover scripts as well.  The reason this happens is because the &lt;span style=&quot;font-weight: bold;&quot;&gt;width &lt;/span&gt;and &lt;span style=&quot;font-weight: bold;&quot;&gt;height &lt;/span&gt;are not defined.&lt;br /&gt;&lt;br /&gt;Does not work:&lt;br /&gt;&amp;lt;img src=&quot;images/exampleLogo.gif&quot; /&amp;gt;&lt;br /&gt;&lt;br /&gt;Works:&lt;br /&gt;&amp;lt;img src=&quot;images/exampleLogo.gif&quot; width=&quot;100&quot; height=&quot;30&quot; /&amp;gt;&lt;br /&gt;&lt;br /&gt;The DTD(see below for img definition) does not require these attributes, however this is the second time I have seen this issue.&lt;br /&gt;&lt;br /&gt;DTD definition for img tag:&lt;br /&gt;&lt;br /&gt;&amp;lt;!ELEMENT img EMPTY&amp;gt;&lt;br /&gt;&amp;lt;!ATTLIST img&lt;br /&gt; %attrs;&lt;br /&gt; src         %URI;          #REQUIRED&lt;br /&gt; alt         %Text;         #REQUIRED&lt;br /&gt; name        NMTOKEN        #IMPLIED&lt;br /&gt; longdesc    %URI;          #IMPLIED&lt;br /&gt; height      %Length;       #IMPLIED&lt;br /&gt; width       %Length;       #IMPLIED&lt;br /&gt; usemap      %URI;          #IMPLIED&lt;br /&gt; ismap       (ismap)        #IMPLIED&lt;br /&gt; align       %ImgAlign;     #IMPLIED&lt;br /&gt; border      %Length;       #IMPLIED&lt;br /&gt; hspace      %Pixels;       #IMPLIED&lt;br /&gt; vspace      %Pixels;       #IMPLIED&lt;br /&gt; &amp;gt;</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/3193323990734841240/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/3193323990734841240' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/3193323990734841240'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/3193323990734841240'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2008/07/image-doesnt-show-up-on-intial-page.html' title='Image(img) doesn&#39;t show up on initial page load, FireFox 2.0.0.16'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11186733.post-4004311475737590146</id><published>2008-07-28T12:38:00.002-04:00</published><updated>2008-07-28T12:42:26.377-04:00</updated><title type='text'>Validate ASP.NET controls independently from one another</title><content type='html'>I had a page that had form validation and then additional validation in a modal state.  They needed to validate independently.  Short of having a true validation framework in place ASP.NET provides Validation Groups to meet these needs.  The link below has a great example and explanation of how it works.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms227424.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/ms227424.aspx&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/4004311475737590146/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/4004311475737590146' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/4004311475737590146'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/4004311475737590146'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2008/07/validate-aspnet-controls-independently.html' title='Validate ASP.NET controls independently from one another'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11186733.post-114987688190625927</id><published>2006-06-09T14:09:00.001-04:00</published><updated>2008-07-31T14:52:22.262-04:00</updated><title type='text'>Breakpoint Workspaces 1.0 Beta</title><content type='html'>&lt;strong&gt;Installer is currently not working, will have it fixed very soon. Sorry&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Breakpoint Workspaces manages breakpoint groups in an external text file so that you can save a set of breakpoints and give it a name that relates to some kind of process you may be working on. You can then load them at will to debug hassle free. Great for digging back into something you may have been working on 6 months ago. I haven&#39;t written any documentation or user instructions, but I tried to make it as easy to use as possible so start clicking away.&lt;br /&gt;&lt;br /&gt;One word of caution, if you have a workspace group you want to load and have not saved your current breakpoints, they will be removed from the project when the workspace is loaded.&lt;br /&gt;&lt;br /&gt;Please send me any feedback you have on bugs, enhancements, ideas...etc Please also keep in mind this is &lt;span style=&quot;FONT-WEIGHT: bold; FONT-STYLE: italic&quot;&gt;beta &lt;/span&gt;software and a tool I have not spend much time on. &lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;I am leaning on the .NET community to shape this into a really nice tool instead of what I think it should be.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Download Add-in here: &lt;a href=&quot;http://www.megaupload.com/?d=DZ66TABC&quot;&gt;http://www.megaupload.com/?d=DZ66TABC&lt;/a&gt;&lt;br /&gt;Contact email: &lt;a href=&quot;mailto:rick_schott2002@yahoo.com&quot;&gt;rick_schott2002@yahoo.com&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;TEXT-ALIGN: center&quot;&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://photos1.blogger.com/blogger/1567/897/1600/bpwksps.0.jpg&quot;&gt;&lt;img style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;http://photos1.blogger.com/blogger/1567/897/320/bpwksps.0.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/114987688190625927/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/114987688190625927' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/114987688190625927'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/114987688190625927'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2006/06/breakpoint-workspaces-10-beta.html' title='Breakpoint Workspaces 1.0 Beta'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11186733.post-111944525147066549</id><published>2005-06-22T08:59:00.000-04:00</published><updated>2005-06-22T09:00:51.536-04:00</updated><title type='text'>Regular Expression Helper Class</title><content type='html'>using System;&lt;br /&gt;using System.Text.RegularExpressions;&lt;br /&gt;&lt;br /&gt;namespace RickSchott.Util&lt;br /&gt;{&lt;br /&gt; /// &lt;summary&gt;&lt;br /&gt; /// Summary description for RegExValidators.&lt;br /&gt; /// &lt;/summary&gt;&lt;br /&gt; public class RegExValidators&lt;br /&gt; {&lt;br /&gt;  public const string regPhoneNumber=@&quot;^(?:\([2-9]\d{2}\)\ ?|[2-9]\d{2}(?:\-?|\ ?))[2-9]\d{2}[- ]?\d{4}$&quot;; &lt;br /&gt;  public const string regEmail = @&quot;^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$&quot;;&lt;br /&gt;  public const string regZipCode = @&quot;^(?(^00000(|-0000))|(\d{5}(|-\d{4})))$&quot;;&lt;br /&gt;  public RegExValidators()&lt;br /&gt;  {&lt;br /&gt;   //&lt;br /&gt;   // TODO: Add constructor logic here&lt;br /&gt;   //&lt;br /&gt;  }&lt;br /&gt;  public static bool isValid(string input,string regConst)&lt;br /&gt;  {   &lt;br /&gt;   return Regex.Match(input,regConst).Success;&lt;br /&gt;  } &lt;br /&gt; }&lt;br /&gt;}</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/111944525147066549/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/111944525147066549' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/111944525147066549'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/111944525147066549'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2005/06/regular-expression-helper-class.html' title='Regular Expression Helper Class'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11186733.post-111521337003054574</id><published>2005-05-04T09:26:00.000-04:00</published><updated>2005-05-04T09:29:30.036-04:00</updated><title type='text'>Stored Procedure Helper Functions</title><content type='html'>public&amp;nbsp;SqlDataReader&amp;nbsp;executeSPHelper(string&amp;nbsp;cmdStr,ArrayList&amp;nbsp;cmdParams)&lt;br /&gt;{  &lt;br /&gt; &lt;br /&gt; SqlDataReader&amp;nbsp;rd=null;  &lt;br /&gt; SqlCommand&amp;nbsp;sqlCmd=null;&lt;br /&gt;&lt;br /&gt; try&lt;br /&gt; {  &lt;br /&gt;&lt;br /&gt;  sqlCmd&amp;nbsp;=&amp;nbsp;new&amp;nbsp;SqlCommand(cmdStr,yourConnection);&lt;br /&gt;  sqlCmd.CommandType&amp;nbsp;=&amp;nbsp;CommandType.StoredProcedure;&lt;br /&gt;&lt;br /&gt;  foreach&amp;nbsp;(SqlParameter&amp;nbsp;sqlParam&amp;nbsp;in&amp;nbsp;cmdParams)&lt;br /&gt;  {&lt;br /&gt;   sqlCmd.Parameters.Add(sqlParam);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  rd&amp;nbsp;=&amp;nbsp;sqlCmd.ExecuteReader();&lt;br /&gt;&lt;br /&gt;  return&amp;nbsp;rd;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; catch(Exception&amp;nbsp;e)&lt;br /&gt; {&lt;br /&gt; }  &lt;br /&gt; finally&lt;br /&gt; {&lt;br /&gt;  sqlCmd=null;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public&amp;nbsp;System.Data.SqlClient.SqlCommand&amp;nbsp;executeSPCommandHelper(string&amp;nbsp;cmdStr,ArrayList&amp;nbsp;cmdParams)&lt;br /&gt;{  &lt;br /&gt;  &lt;br /&gt; SqlCommand&amp;nbsp;sqlCmd=null;&lt;br /&gt;&lt;br /&gt; try&lt;br /&gt; {  &lt;br /&gt;&lt;br /&gt;  sqlCmd&amp;nbsp;=&amp;nbsp;new&amp;nbsp;SqlCommand(cmdStr,yourConnection);&lt;br /&gt;  sqlCmd.CommandType&amp;nbsp;=&amp;nbsp;CommandType.StoredProcedure;&lt;br /&gt;&lt;br /&gt;  foreach&amp;nbsp;(SqlParameter&amp;nbsp;sqlParam&amp;nbsp;in&amp;nbsp;cmdParams)&lt;br /&gt;  {&lt;br /&gt;   sqlCmd.Parameters.Add(sqlParam);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  //rd&amp;nbsp;=&amp;nbsp;sqlCmd.ExecuteReader();&lt;br /&gt;&lt;br /&gt;  return&amp;nbsp;sqlCmd;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; catch(Exception&amp;nbsp;e)&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt; }  &lt;br /&gt; finally&lt;br /&gt; {&lt;br /&gt;  sqlCmd=null;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public&amp;nbsp;System.Data.SqlClient.SqlCommand&amp;nbsp;executeSPCommandHelper(string&amp;nbsp;cmdStr)&lt;br /&gt;{  &lt;br /&gt; &lt;br /&gt; SqlCommand&amp;nbsp;sqlCmd=null;&lt;br /&gt;&lt;br /&gt; try&lt;br /&gt; {  &lt;br /&gt;&lt;br /&gt;  sqlCmd&amp;nbsp;=&amp;nbsp;new&amp;nbsp;SqlCommand(cmdStr,yourConnection);&lt;br /&gt;  sqlCmd.CommandType&amp;nbsp;=&amp;nbsp;CommandType.StoredProcedure;  &lt;br /&gt;&lt;br /&gt;  return&amp;nbsp;sqlCmd;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; catch(Exception&amp;nbsp;e)&lt;br /&gt; {&lt;br /&gt; }  &lt;br /&gt; finally&lt;br /&gt; {&lt;br /&gt;  sqlCmd=null;&lt;br /&gt; }&lt;br /&gt;}</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/111521337003054574/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/111521337003054574' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/111521337003054574'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/111521337003054574'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2005/05/stored-procedure-helper-functions.html' title='Stored Procedure Helper Functions'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11186733.post-111042542342141194</id><published>2005-03-09T22:27:00.000-05:00</published><updated>2005-03-09T22:32:43.210-05:00</updated><title type='text'>Code 39 Mod 43 barcode checkdigit function</title><content type='html'>//pass in a string and returns string with check digit&lt;br /&gt;public string getCode39Mod43(string s)&lt;br /&gt;{&lt;br /&gt;int sum = 0;&lt;br /&gt;string temps = s.ToUpper();&lt;br /&gt;for(int i=0;i&lt;temps.length;i++)&gt;{&lt;br /&gt;sum += AsciiToCharTable(temps[i]);&lt;br /&gt;}&lt;br /&gt;int mod = sum % 43;&lt;br /&gt;return temps + CharTableToString(mod);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public int AsciiToCharTable(char c)&lt;br /&gt;{&lt;br /&gt;if(c==48)//0&lt;br /&gt;{&lt;br /&gt;return 0;&lt;br /&gt;}&lt;br /&gt;else if(c==49)//1&lt;br /&gt;{&lt;br /&gt;return 1;&lt;br /&gt;}&lt;br /&gt;else if(c==50)//2&lt;br /&gt;{&lt;br /&gt;return 2;&lt;br /&gt;}&lt;br /&gt;else if(c==51)//3&lt;br /&gt;{&lt;br /&gt;return 3;&lt;br /&gt;}&lt;br /&gt;else if(c==52)//4&lt;br /&gt;{&lt;br /&gt;return 4;&lt;br /&gt;}&lt;br /&gt;else if(c==53)//5&lt;br /&gt;{&lt;br /&gt;return 5;&lt;br /&gt;}&lt;br /&gt;else if(c==54)//6&lt;br /&gt;{&lt;br /&gt;return 6;&lt;br /&gt;}&lt;br /&gt;else if(c==55)//7&lt;br /&gt;{&lt;br /&gt;return 7;&lt;br /&gt;}&lt;br /&gt;else if(c==56)//8&lt;br /&gt;{&lt;br /&gt;return 8;&lt;br /&gt;}&lt;br /&gt;else if(c==57)//9&lt;br /&gt;{&lt;br /&gt;return 9;&lt;br /&gt;}&lt;br /&gt;else if(c==65)//A&lt;br /&gt;{&lt;br /&gt;return 10;&lt;br /&gt;}&lt;br /&gt;else if(c==66)//B&lt;br /&gt;{&lt;br /&gt;return 11;&lt;br /&gt;}&lt;br /&gt;else if(c==67)//C&lt;br /&gt;{&lt;br /&gt;return 12;&lt;br /&gt;}&lt;br /&gt;else if(c==68)//D&lt;br /&gt;{&lt;br /&gt;return 13;&lt;br /&gt;}&lt;br /&gt;else if(c==69)//E&lt;br /&gt;{&lt;br /&gt;return 14;&lt;br /&gt;}&lt;br /&gt;else if(c==70)//F&lt;br /&gt;{&lt;br /&gt;return 15;&lt;br /&gt;}&lt;br /&gt;else if(c==71)//G&lt;br /&gt;{&lt;br /&gt;return 16;&lt;br /&gt;}&lt;br /&gt;else if(c==72)//H&lt;br /&gt;{&lt;br /&gt;return 17;&lt;br /&gt;}&lt;br /&gt;else if(c==73)//I&lt;br /&gt;{&lt;br /&gt;return 18;&lt;br /&gt;}&lt;br /&gt;else if(c==74)//J&lt;br /&gt;{&lt;br /&gt;return 19;&lt;br /&gt;}&lt;br /&gt;else if(c==75)//K&lt;br /&gt;{&lt;br /&gt;return 20;&lt;br /&gt;}&lt;br /&gt;else if(c==76)//L&lt;br /&gt;{&lt;br /&gt;return 21;&lt;br /&gt;}&lt;br /&gt;else if(c==77)//M&lt;br /&gt;{&lt;br /&gt;return 22;&lt;br /&gt;}&lt;br /&gt;else if(c==78)//N&lt;br /&gt;{&lt;br /&gt;return 23;&lt;br /&gt;}&lt;br /&gt;else if(c==79)//O&lt;br /&gt;{&lt;br /&gt;return 24;&lt;br /&gt;}&lt;br /&gt;else if(c==80)//P&lt;br /&gt;{&lt;br /&gt;return 25;&lt;br /&gt;}&lt;br /&gt;else if(c==81)//Q&lt;br /&gt;{&lt;br /&gt;return 26;&lt;br /&gt;}&lt;br /&gt;else if(c==82)//R&lt;br /&gt;{&lt;br /&gt;return 27;&lt;br /&gt;}&lt;br /&gt;else if(c==83)//S&lt;br /&gt;{&lt;br /&gt;return 28;&lt;br /&gt;}&lt;br /&gt;else if(c==84)//T&lt;br /&gt;{&lt;br /&gt;return 29;&lt;br /&gt;}&lt;br /&gt;else if(c==85)//U&lt;br /&gt;{&lt;br /&gt;return 30;&lt;br /&gt;}&lt;br /&gt;else if(c==86)//V&lt;br /&gt;{&lt;br /&gt;return 31;&lt;br /&gt;}&lt;br /&gt;else if(c==87)//W&lt;br /&gt;{&lt;br /&gt;return 32;&lt;br /&gt;}&lt;br /&gt;else if(c==88)//X&lt;br /&gt;{&lt;br /&gt;return 33;&lt;br /&gt;}&lt;br /&gt;else if(c==89)//Y&lt;br /&gt;{&lt;br /&gt;return 34;&lt;br /&gt;}&lt;br /&gt;else if(c==90)//Z&lt;br /&gt;{&lt;br /&gt;return 35;&lt;br /&gt;}&lt;br /&gt;else if(c==45)//-&lt;br /&gt;{&lt;br /&gt;return 36;&lt;br /&gt;}&lt;br /&gt;else if(c==46)//.&lt;br /&gt;{&lt;br /&gt;return 37;&lt;br /&gt;}&lt;br /&gt;else if(c==32)//sp&lt;br /&gt;{&lt;br /&gt;return 38;&lt;br /&gt;}&lt;br /&gt;else if(c==36)//$&lt;br /&gt;{&lt;br /&gt;return 39;&lt;br /&gt;}&lt;br /&gt;else if(c==47)///&lt;br /&gt;{&lt;br /&gt;return 40;&lt;br /&gt;}&lt;br /&gt;else if(c==43)//+&lt;br /&gt;{&lt;br /&gt;return 41;&lt;br /&gt;}&lt;br /&gt;else if(c==37)//%&lt;br /&gt;{&lt;br /&gt;return 42;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;return 0;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public string CharTableToString(int c)&lt;br /&gt;{&lt;br /&gt;if(c==0)//0&lt;br /&gt;{&lt;br /&gt;return &quot;0&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==1)//1&lt;br /&gt;{&lt;br /&gt;return &quot;1&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==2)//2&lt;br /&gt;{&lt;br /&gt;return &quot;2&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==3)//3&lt;br /&gt;{&lt;br /&gt;return &quot;3&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==4)//4&lt;br /&gt;{&lt;br /&gt;return &quot;4&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==5)//5&lt;br /&gt;{&lt;br /&gt;return &quot;5&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==6)//6&lt;br /&gt;{&lt;br /&gt;return &quot;6&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==7)//7&lt;br /&gt;{&lt;br /&gt;return &quot;7&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==8)//8&lt;br /&gt;{&lt;br /&gt;return &quot;8&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==9)//9&lt;br /&gt;{&lt;br /&gt;return &quot;9&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==10)//A&lt;br /&gt;{&lt;br /&gt;return &quot;A&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==11)//B&lt;br /&gt;{&lt;br /&gt;return &quot;B&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==12)//C&lt;br /&gt;{&lt;br /&gt;return &quot;C&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==13)//D&lt;br /&gt;{&lt;br /&gt;return &quot;D&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==14)//E&lt;br /&gt;{&lt;br /&gt;return &quot;E&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==15)//F&lt;br /&gt;{&lt;br /&gt;return &quot;F&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==16)//G&lt;br /&gt;{&lt;br /&gt;return &quot;G&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==17)//H&lt;br /&gt;{&lt;br /&gt;return &quot;H&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==18)//I&lt;br /&gt;{&lt;br /&gt;return &quot;I&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==19)//J&lt;br /&gt;{&lt;br /&gt;return &quot;J&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==20)//K&lt;br /&gt;{&lt;br /&gt;return &quot;K&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==21)//L&lt;br /&gt;{&lt;br /&gt;return &quot;L&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==22)//M&lt;br /&gt;{&lt;br /&gt;return &quot;M&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==23)//N&lt;br /&gt;{&lt;br /&gt;return &quot;N&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==24)//O&lt;br /&gt;{&lt;br /&gt;return &quot;O&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==25)//P&lt;br /&gt;{&lt;br /&gt;return &quot;P&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==26)//Q&lt;br /&gt;{&lt;br /&gt;return &quot;Q&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==27)//R&lt;br /&gt;{&lt;br /&gt;return &quot;R&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==28)//S&lt;br /&gt;{&lt;br /&gt;return &quot;S&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==29)//T&lt;br /&gt;{&lt;br /&gt;return &quot;T&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==30)//U&lt;br /&gt;{&lt;br /&gt;return &quot;U&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==31)//V&lt;br /&gt;{&lt;br /&gt;return &quot;V&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==32)//W&lt;br /&gt;{&lt;br /&gt;return &quot;W&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==33)//X&lt;br /&gt;{&lt;br /&gt;return &quot;X&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==34)//Y&lt;br /&gt;{&lt;br /&gt;return &quot;Y&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==35)//Z&lt;br /&gt;{&lt;br /&gt;return &quot;Z&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==36)//-&lt;br /&gt;{&lt;br /&gt;return &quot;-&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==37)//.&lt;br /&gt;{&lt;br /&gt;return &quot;.&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==38)//sp&lt;br /&gt;{&lt;br /&gt;return &quot; &quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==39)//$&lt;br /&gt;{&lt;br /&gt;return &quot;$&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==40)///&lt;br /&gt;{&lt;br /&gt;return &quot;/&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==41)//+&lt;br /&gt;{&lt;br /&gt;return &quot;+&quot;;&lt;br /&gt;}&lt;br /&gt;else if(c==42)//%&lt;br /&gt;{&lt;br /&gt;return &quot;%&quot;;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;return &quot;&quot;;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/111042542342141194/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/111042542342141194' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/111042542342141194'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/111042542342141194'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2005/03/code-39-mod-43-barcode-checkdigit.html' title='Code 39 Mod 43 barcode checkdigit function'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11186733.post-110986221358286586</id><published>2005-03-03T10:00:00.000-05:00</published><updated>2005-03-03T10:20:42.113-05:00</updated><title type='text'>Thread safe C# logging class using the Singleton Pattern</title><content type='html'>&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;using System;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.IO;&lt;br /&gt;using System.Configuration;&lt;br /&gt;&lt;br /&gt;namespace Logger&lt;br /&gt;{&lt;br /&gt;  /// &lt;summary&gt;&lt;br /&gt;  /// Summary description for Logger.&lt;br /&gt;  /// &lt;/summary&gt;&lt;br /&gt;  public class Logger&lt;br /&gt;  {&lt;br /&gt;&lt;br /&gt;    private static System.IO.StreamWriter _Output = null;&lt;br /&gt;    private static Logger _Logger = null;&lt;br /&gt;    private static Object _classLock = typeof(Logger);&lt;br /&gt;    public static string _LogFile = &quot;&quot;;&lt;br /&gt;    public static int _LogLevel = 1;&lt;br /&gt;&lt;br /&gt;    private Logger()&lt;br /&gt;    {&lt;br /&gt;     &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public static Logger getInstance()&lt;br /&gt;    {&lt;br /&gt;      //lock object to make it thread safe&lt;br /&gt;      lock(_classLock)&lt;br /&gt;      {&lt;br /&gt;        if(_Logger==null)&lt;br /&gt;        {&lt;br /&gt;          _Logger = new Logger();&lt;br /&gt;        &lt;br /&gt;        }&lt;br /&gt;      }&lt;br /&gt;      return _Logger;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public static void logError(string s, int severity)&lt;br /&gt;    {&lt;br /&gt;      try&lt;br /&gt;      {&lt;br /&gt;        if(severity &lt;=_LogLevel)&lt;br /&gt;        {&lt;br /&gt;          if (_Output==null)&lt;br /&gt;          {&lt;br /&gt;            _Output = new System.IO.StreamWriter(_LogFile, true, System.Text.UnicodeEncoding.Default);&lt;br /&gt;          }&lt;br /&gt;                  &lt;br /&gt;          _Output.WriteLine(System.DateTime.Now + &quot; &quot; + s,new object[0]);&lt;br /&gt;                  &lt;br /&gt;          if (_Output != null)&lt;br /&gt;          {&lt;br /&gt;            _Output.Close();&lt;br /&gt;            _Output = null;&lt;br /&gt;          }&lt;br /&gt;        }&lt;br /&gt;      }&lt;br /&gt;      catch(Exception ex)&lt;br /&gt;      {&lt;br /&gt;        Console.WriteLine(ex.Message,new object[0]);      &lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public static void closeLog()&lt;br /&gt;    {&lt;br /&gt;      try&lt;br /&gt;      {&lt;br /&gt;        if (_Output != null)&lt;br /&gt;        {&lt;br /&gt;          _Output.Close();&lt;br /&gt;          _Output = null;&lt;br /&gt;        }&lt;br /&gt;      }&lt;br /&gt;      catch(Exception ex)&lt;br /&gt;      {&lt;br /&gt;        Console.WriteLine(ex.Message,new object[0]);&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/110986221358286586/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/110986221358286586' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/110986221358286586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/110986221358286586'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2005/03/thread-safe-c-logging-class-using.html' title='Thread safe C# logging class using the Singleton Pattern'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11186733.post-110978945065563799</id><published>2005-03-02T13:39:00.000-05:00</published><updated>2005-03-04T16:35:53.816-05:00</updated><title type='text'>Impersonation for data access with LogonUser</title><content type='html'>Using the example code from URL below and a little modification.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemSecurityPrincipalWindowsIdentityClassImpersonateTopic.asp&quot;&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemSecurityPrincipalWindowsIdentityClassImpersonateTopic.asp&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I made myself a class that would call LogonUser.&lt;br /&gt;See below:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#6666cc;&quot;&gt;using System;&lt;br /&gt;using System.Runtime.InteropServices;&lt;br /&gt;using System.Security.Principal;&lt;br /&gt;using System.Security.Permissions;&lt;br /&gt;&lt;br /&gt;[assembly:SecurityPermissionAttribute(SecurityAction.RequestMinimum, UnmanagedCode=true)]&lt;br /&gt;[assembly:PermissionSetAttribute(SecurityAction.RequestMinimum, Name = &quot;FullTrust&quot;)]&lt;br /&gt;namespace Impersonation&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;public class Impersonation&lt;br /&gt;{&lt;br /&gt;[DllImport(&quot;advapi32.dll&quot;, SetLastError=true)]&lt;br /&gt;public static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword,&lt;br /&gt;int dwLogonType, int dwLogonProvider, ref IntPtr phToken);&lt;br /&gt;&lt;br /&gt;[DllImport(&quot;kernel32.dll&quot;, CharSet=System.Runtime.InteropServices.CharSet.Auto)]&lt;br /&gt;private unsafe static extern int FormatMessage(int dwFlags, ref IntPtr lpSource,&lt;br /&gt;int dwMessageId, int dwLanguageId, ref String lpBuffer, int nSize, IntPtr *Arguments);&lt;br /&gt;&lt;br /&gt;[DllImport(&quot;kernel32.dll&quot;, CharSet=CharSet.Auto)]&lt;br /&gt;public extern static bool CloseHandle(IntPtr handle);&lt;br /&gt;&lt;br /&gt;[DllImport(&quot;advapi32.dll&quot;, CharSet=CharSet.Auto, SetLastError=true)]&lt;br /&gt;public extern static bool DuplicateToken(IntPtr ExistingTokenHandle,&lt;br /&gt;int SECURITY_IMPERSONATION_LEVEL, ref IntPtr DuplicateTokenHandle);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// GetErrorMessage formats and returns an error message&lt;br /&gt;// corresponding to the input errorCode.&lt;br /&gt;public unsafe static string GetErrorMessage(int errorCode)&lt;br /&gt;{&lt;br /&gt;int FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100;&lt;br /&gt;int FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200;&lt;br /&gt;int FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000;&lt;br /&gt;&lt;br /&gt;int messageSize = 255;&lt;br /&gt;String lpMsgBuf = &quot;&quot;;&lt;br /&gt;int dwFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER FORMAT_MESSAGE_FROM_SYSTEM FORMAT_MESSAGE_IGNORE_INSERTS;&lt;br /&gt;&lt;br /&gt;IntPtr ptrlpSource = IntPtr.Zero;&lt;br /&gt;IntPtr prtArguments = IntPtr.Zero;&lt;br /&gt;&lt;br /&gt;int retVal = FormatMessage(dwFlags, ref ptrlpSource, errorCode, 0, ref lpMsgBuf, messageSize, &amp;prtArguments);&lt;br /&gt;if (0 == retVal)&lt;br /&gt;{&lt;br /&gt;throw new Exception(&quot;Failed to format message for error code &quot; + errorCode + &quot;. &quot;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;return lpMsgBuf;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Test harness.&lt;br /&gt;// If you incorporate this code into a DLL, be sure to demand FullTrust.&lt;br /&gt;[PermissionSetAttribute(SecurityAction.Demand, Name = &quot;FullTrust&quot;)]&lt;br /&gt;public void impersonateThis(string username, string password, string domainname)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;IntPtr tokenHandle = new IntPtr(0);&lt;br /&gt;IntPtr dupeTokenHandle = new IntPtr(0);&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;string userName, domainName;&lt;br /&gt;&lt;br /&gt;domainName = domainname;&lt;br /&gt;&lt;br /&gt;userName = username;&lt;br /&gt;&lt;br /&gt;const int LOGON32_PROVIDER_DEFAULT = 0;&lt;br /&gt;//This parameter causes LogonUser to create a primary token.&lt;br /&gt;const int LOGON32_LOGON_INTERACTIVE = 2;&lt;br /&gt;const int SecurityImpersonation = 2;&lt;br /&gt;&lt;br /&gt;tokenHandle = IntPtr.Zero;&lt;br /&gt;dupeTokenHandle = IntPtr.Zero;&lt;br /&gt;&lt;br /&gt;bool returnValue = LogonUser(userName, domainName, password,&lt;br /&gt;LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT,&lt;br /&gt;ref tokenHandle);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (false == returnValue)&lt;br /&gt;{&lt;br /&gt;int ret = Marshal.GetLastWin32Error();&lt;br /&gt;Console.WriteLine(&quot;LogonUser failed with error code : {0}&quot;, ret);&lt;br /&gt;Console.WriteLine(&quot;\nError: [{0}] {1}\n&quot;, ret, GetErrorMessage(ret));&lt;br /&gt;int errorCode = 0x5; //ERROR_ACCESS_DENIED&lt;br /&gt;throw new System.ComponentModel.Win32Exception(errorCode);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;bool retVal = DuplicateToken(tokenHandle, SecurityImpersonation, ref dupeTokenHandle);&lt;br /&gt;if (false == retVal)&lt;br /&gt;{&lt;br /&gt;CloseHandle(tokenHandle);&lt;br /&gt;Console.WriteLine(&quot;Exception thrown in trying to duplicate token.&quot;);&lt;br /&gt;return;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// The token that is passed to the following constructor must&lt;br /&gt;// be a primary token in order to use it for impersonation.&lt;br /&gt;WindowsIdentity newId = new WindowsIdentity(dupeTokenHandle);&lt;br /&gt;WindowsImpersonationContext impersonatedUser = newId.Impersonate();&lt;br /&gt;&lt;br /&gt;// Free the tokens.&lt;br /&gt;if (tokenHandle != IntPtr.Zero)&lt;br /&gt;CloseHandle(tokenHandle);&lt;br /&gt;if (dupeTokenHandle != IntPtr.Zero)&lt;br /&gt;CloseHandle(dupeTokenHandle);&lt;br /&gt;}&lt;br /&gt;catch(Exception ex)&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;finally&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;Once I had my class created I called the impersonateThis funtion when opening my connection inside my data access class.&lt;br /&gt;See below:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;public void openConnection(String connectionString)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;Impersonation mi = new Impersonation();&lt;br /&gt;mi.impersonateThis(&quot;user&quot;,&quot;password&quot;,&quot;domainname&quot;);&lt;br /&gt;&lt;br /&gt;sqlConn = new SqlConnection(connectionString);&lt;br /&gt;sqlConn.Open();&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;catch(Exception ex)&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;finally&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;The result of this is that when calling these classes from ASP.NET the code runs under aspnet account but when the openConnection function is called the impersonation kicks in and you are running under the impersonated account; which in my case happens to be a user setup in my SQL Server database and magic happens. When the code block is done and returns to the .aspx code behind page the impersonation is released and you are now running under the aspnet account again. To test this you can call WindowsIdentity.GetCurrent().Name to see what account you are running under when.</content><link rel='replies' type='application/atom+xml' href='http://cooldotnetstuff.blogspot.com/feeds/110978945065563799/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11186733/110978945065563799' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/110978945065563799'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11186733/posts/default/110978945065563799'/><link rel='alternate' type='text/html' href='http://cooldotnetstuff.blogspot.com/2005/03/impersonation-for-data-access-with.html' title='Impersonation for data access with LogonUser'/><author><name>_rick_schott</name><uri>http://www.blogger.com/profile/17749694806371339736</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>