<?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>Greg K&#039;s Blog</title>
	<atom:link href="http://www.kps-fl.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.kps-fl.com/blog</link>
	<description>All Work and No Play Make for a Dull Day!</description>
	<lastBuildDate>Tue, 18 Oct 2011 18:59:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Enterprise Library 5.0 &#8211; How to use the Data Access Application Block</title>
		<link>http://www.kps-fl.com/blog/?p=40</link>
		<comments>http://www.kps-fl.com/blog/?p=40#comments</comments>
		<pubDate>Tue, 18 Oct 2011 18:59:26 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.kps-fl.com/blog/?p=40</guid>
		<description><![CDATA[I have been using the Enterprise Library from Microsoft&#8217;s Patterns and Practices even before it was officially named in 2006 (version 2.0). I use it in all of my .NET applications including windows, web and web services. It still amazes &#8230; <a href="http://www.kps-fl.com/blog/?p=40">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have been using the Enterprise Library from Microsoft&#8217;s Patterns and Practices even before it was officially named in 2006 (version 2.0).  I use it in all of my .NET applications including windows, web and web services. It still amazes me that companies and developers have not adopted the use of something that is so simple to use instead of writing your own custom data access provider. The following is going to show you how to use the latest Enterprise Library 5.0 which you can read more about <a href="http://msdn.microsoft.com/en-us/library/ff648951.aspx">here</a>. The Enterprise Library comes with several other application blocks but this post will only focus on the Data Access application block. This will also assume you have a stored procedure created in your SQL Server or Oracle database &#8211; Yes, <strong>this code will work for both SQL Server AND Oracle without changing anything except your connection string</strong> in the web.config file.  How cool is that?</p>
<p><strong><em>Download and Installation</em></strong><br />
The first thing you need to do is download and install the Enterprise Library in order to get the .dll files needed for the data application block. As of EntLib 5.0, you will need 5 .dll files:</p>
<ul>
<li>Microsoft.Practices.EnterpriseLibrary.Common.dll</li>
<li>Microsoft.Practices.EnterpriseLibrary.Data.dll</li>
<li>Microsoft.Practices.ServiceLocation.dll</li>
<li>Microsoft.Practices.Unity.dll</li>
<li>Microsoft.Practices.Unity.Interception.dll</li>
</ul>
<p>Once installed you can find these files in the C:\Program Files (x86)\Microsoft Enterprise Library 5.0\Bin folder if you used the default installation options.</p>
<p><strong><em>Referencing the Enterprise Library assemblies</em></strong><br />
Let&#8217;s assume you are working on an ASP.NET web applicaiton. I typically create a folder in my project that contains all of the third party libraries and then copy the .dll files that I need to that folder. Instead of referencing the location of the installed dll files, I reference the files that are in my folder. This allows for easy maintenance of third party libraries as well as now I don&#8217;t need to have the EntLib installed on other machines.  You can use this structure in windows applications as well.</p>
<p><strong><em>Code Setup</em></strong><br />
Ok, so we have added the references to our web application and we are ready to create the database connection and do some coding.  With EntLib 5.0, there is nothing you have to add to the web.config to make this work for the data application block. The only thing you need to have is a ConnectionString section properly configured to connect to your database.  Let&#8217;s use the default connection string name of LocalSqlServer in the web.config.</p>
<p>We need to create a Database object that we will use as our connection. I typically have a public common class that I put this in. So, I&#8217;m going to add a using statement and then add a public static variable for my connection.</p>
<pre class="brush: csharp; title: ; notranslate">
// Add this to the using statements
using Microsoft.Practices.EnterpriseLibrary.Data;

public class _Common
{
    public static Database dbConn = DatabaseFactory.CreateDatabase(&quot;LocalSqlServer&quot;);
}
</pre>
<p>Next, let&#8217;s code a function in the business logic layer that uses the connection, adds some parameters, and calls the stored procedure and returns a dataset with the results.</p>
<pre class="brush: csharp; title: ; notranslate">
using System;
using System.Data;
using System.Data.Common;
using System.Web;

    public class _Event
    {
        #region Variables
        private string _EventName;
        private string _EventDesc;
        #endregion

        #region Properties
        public int EventId { get; set; }
        public string EventName
        {
            get { return _EventName; }
            set { _EventName = value.Trim(); }
        }
        public string EventDesc
        {
            get { return _EventDesc; }
            set { _EventDesc = value.Trim(); }
        }
        public bool bCompleted { get; set; }
        #endregion

        #region Methods
        ///
        /// Selects all events.
        ///
        public bool SelectEvents(ref DataSet objDS)
        {
            try
            {
                DbCommand cmd = _Common.dbConn.GetStoredProcCommand(&quot;usp_Event_Sel&quot;);
                _Common.dbConn.AddInParameter(cmd, &quot;bIncludeCompleted&quot;, DbType.Boolean, bCompleted);
                objDS = _Common.dbConn.ExecuteDataSet(cmd);
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion
    }
</pre>
<p>As you can see, I have created a method called SelectEvents that takes a DataSet as a parameter.  This will be the dataset that gets populated.  The method returns a bool indicating success or failure of the method.  The name of the stored procedure I am calling is <em>usp_Event_Sel</em>.  You will also see that I have used a parameter called bIncludeCompleted.  This is the parameter that the stored procedure accepts.  Then, I call ExecuteDataSet on my database connection dbConn, pass in the DbCommand object cmd and assign the result to my passed in DataSet.</p>
<p>A few last notes.  By using the try-catch block, you will return any error messages that the stored procedure throws.  The nice thing about this is that any Raiserror functions will return that message and you can display it to the user.  Sometimes you have to do database checks before you execute an INSERT or UPDATE in a stored procedure and you can return any problems with these checks through the raiserror function to let your user know what is happening.</p>
<p>You can also add output parameters by calling the AddOutParameter function in the same way as the AddInParameter.  Likewise, you can simply call ExecuteNonQuery or ExecuteDataReader if you need that functionality.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kps-fl.com/blog/?feed=rss2&#038;p=40</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HP Laptop, IE9, and Netflix Crash</title>
		<link>http://www.kps-fl.com/blog/?p=38</link>
		<comments>http://www.kps-fl.com/blog/?p=38#comments</comments>
		<pubDate>Wed, 22 Jun 2011 03:17:57 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.kps-fl.com/blog/?p=38</guid>
		<description><![CDATA[Well, got done fixing the wife&#8217;s HP laptop. Apparently, everytime it would go to netflix.com, IE9 would crash. A look in the event viewer notified me that the Digital Persona Fingerprint plugin was causing the crash. It was attempting to &#8230; <a href="http://www.kps-fl.com/blog/?p=38">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Well, got done fixing the wife&#8217;s HP laptop.  Apparently, everytime it would go to netflix.com, IE9 would crash.  A look in the event viewer notified me that the Digital Persona Fingerprint plugin was causing the crash.  It was attempting to load an IE8 plugin for IE9.  Uh, no, I don&#8217;t think that will work.  So, if you have the above scenario, disable the Digital Persona plugin in IE9 and then you should be able to go to Netflix to watch movies instantly.</p>
<p>Greg</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kps-fl.com/blog/?feed=rss2&#038;p=38</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>2011 Pictures Posted!</title>
		<link>http://www.kps-fl.com/blog/?p=34</link>
		<comments>http://www.kps-fl.com/blog/?p=34#comments</comments>
		<pubDate>Sat, 28 May 2011 02:45:55 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.kps-fl.com/blog/?p=34</guid>
		<description><![CDATA[Sorry, I got busy again and didn&#8217;t get the pictures posted for 2011 when I had promised but they are there now! They included some of the Royal Gorge train ride we took when the parents were here, Michele&#8217;s promotion &#8230; <a href="http://www.kps-fl.com/blog/?p=34">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Sorry, I got busy again and didn&#8217;t get the pictures posted for 2011 when I had promised but they are there now!  They included some of the Royal Gorge train ride we took when the parents were here, Michele&#8217;s promotion to Lt. Colonel and then some other pictures of the kids.  Enjoy!</p>
<p>Greg</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kps-fl.com/blog/?feed=rss2&#038;p=34</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Pictures and Update</title>
		<link>http://www.kps-fl.com/blog/?p=32</link>
		<comments>http://www.kps-fl.com/blog/?p=32#comments</comments>
		<pubDate>Sat, 14 May 2011 13:59:23 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.kps-fl.com/blog/?p=32</guid>
		<description><![CDATA[Well, I&#8217;ve had some time to get pictures organized finally. I&#8217;ve got all of the pictures uploading through 2010 and will be working on 2011 ones this weekend. Sorry, it has taken so long but I have switched image viewers &#8230; <a href="http://www.kps-fl.com/blog/?p=32">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Well, I&#8217;ve had some time to get pictures organized finally.  I&#8217;ve got all of the pictures uploading through 2010 and will be working on 2011 ones this weekend.  Sorry, it has taken so long but I have switched image viewers (again) from Silverlight to using LightBox2 which is very nice.  I don&#8217;t have to manually code each image as now it just looks in a folder and loads them all dynamically.  </p>
<p>I also finally got a client&#8217;s website updated with a new design &#8211; www.bluedolphincottages.com.  Check it out!</p>
<p>Greg</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kps-fl.com/blog/?feed=rss2&#038;p=32</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WCF Service and Silverlight</title>
		<link>http://www.kps-fl.com/blog/?p=29</link>
		<comments>http://www.kps-fl.com/blog/?p=29#comments</comments>
		<pubDate>Thu, 20 Jan 2011 02:42:31 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.kps-fl.com/blog/?p=29</guid>
		<description><![CDATA[Well, I&#8217;m venturing out into new technology using WCF and Silverlight 4.0. I learned something today that was quite interesting. So, my task was to come up with a new web service (now called a WCF Service in 4.0) that &#8230; <a href="http://www.kps-fl.com/blog/?p=29">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Well, I&#8217;m venturing out into new technology using WCF and Silverlight 4.0.  I learned something today that was quite interesting.</p>
<p>So, my task was to come up with a new web service (now called a WCF Service in 4.0) that can handle encrypting and decrypting strings in a Silverlight application.  So, I create a WCF Service (aka Web Service) that would handle the routines on the server side.  Then, all I need to do is use the existing class in the Silverlight application right?  WRONG!  Apparently, Silverlight applications have limited capabilities to namespaces like System.Security.Cryptography and System.Text to just name a few.  So, I had to Google to come up with another solution.  So instead of using the Rijndael algorithm, I had to use the Rfc2898DeriveBytes algorithm.  Worked like a charm!</p>
<p>Anyway, it was a learning day in the world of .NET 4.0 and Silverlight!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kps-fl.com/blog/?feed=rss2&#038;p=29</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Password Keeper v1.83 now available!</title>
		<link>http://www.kps-fl.com/blog/?p=24</link>
		<comments>http://www.kps-fl.com/blog/?p=24#comments</comments>
		<pubDate>Mon, 10 Jan 2011 20:48:59 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.kps-fl.com/blog/?p=24</guid>
		<description><![CDATA[Password Keeper v1.83 is now available.  I had to revise the licensing mechanism so if you have licensed your product from an earlier version, you will need to re-request a new license once 1.83 is installed. Thanks, Greg]]></description>
			<content:encoded><![CDATA[<p>Password Keeper v1.83 is now available.  I had to revise the licensing mechanism so if you have licensed your product from an earlier version, you will need to re-request a new license once 1.83 is installed.</p>
<p>Thanks,<br />
Greg</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kps-fl.com/blog/?feed=rss2&#038;p=24</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Merry Christmas!</title>
		<link>http://www.kps-fl.com/blog/?p=19</link>
		<comments>http://www.kps-fl.com/blog/?p=19#comments</comments>
		<pubDate>Wed, 22 Dec 2010 04:23:13 +0000</pubDate>
		<dc:creator>gknierim</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.kps-fl.com/blog/?p=19</guid>
		<description><![CDATA[Well, the Christmas Holidays are upon us.  As I reflect on this year, a lot has happened in my life with starting the year out with shoulder surgery, to the relocation from Florida to Colorado over the summer, selling a house &#8230; <a href="http://www.kps-fl.com/blog/?p=19">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Well, the Christmas Holidays are upon us.  As I reflect on this year, a lot has happened in my life with starting the year out with shoulder surgery, to the relocation from Florida to Colorado over the summer, selling a house and renting another, and the career change from being happy at a permanent job in FL to a wonderful contract job in CO (I really did like it!). </p>
<p>So as we reflect on the year, look back at what has happened in your life, whether good and bad, and learn from it.  Things could be worse but be happy with what you have and don&#8217;t envy what you don&#8217;t.  Merry Christmas to all my family and friends and we&#8217;ll see you back in FL for the holidays!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kps-fl.com/blog/?feed=rss2&#038;p=19</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WebProfile Builder and WAP for VS2010</title>
		<link>http://www.kps-fl.com/blog/?p=17</link>
		<comments>http://www.kps-fl.com/blog/?p=17#comments</comments>
		<pubDate>Sat, 11 Dec 2010 01:08:33 +0000</pubDate>
		<dc:creator>gknierim</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://kps-fl.com.poppy.arvixe.com/blog/?p=17</guid>
		<description><![CDATA[Oh Microsoft, how I wish you would just make things work consistently.  I&#8217;ve been using the WebProfile Builder for my Web Application Projects (WAPs) for quite some time now.  Now that I am converting everything over to .NET 4.0, I &#8230; <a href="http://www.kps-fl.com/blog/?p=17">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Oh Microsoft, how I wish you would just make things work consistently.  I&#8217;ve been using the WebProfile Builder for my Web Application Projects (WAPs) for quite some time now.  Now that I am converting everything over to .NET 4.0, I have come across a problem when creating a new web application project and how it references Profile properties. </p>
<p>So, the first thing that you NEED to know: Web Application Projects and Web Site projects are not the same thing!  If you create a Web Site project, the Profile class is automatically generated and you can begin using it by creating your web.config entries and then referring to Profile.whatever in your code.  This is, and has been, not the case for web application projects.</p>
<p>So, amongst my research I have finally figured this out.  The first step is to install the Web Profile Builder version 1.3.  Note that unlike in previous versions, when you open your project and right click on the web.config file, you will NOT see the Build WebProfile option.  You must do a few other things to get this to work.</p>
<p>The next step is to open up your project file (.vbproj or .csproj) and add the following Import line: &lt;Import Project=&#8221;$(MSBuildExtensionsPath)\WebProfileBuilder\WebProfileBuilder.targets&#8221; /&gt;  If you are working on a 64 bit system, make sure you use MSBuildExtensionsPath32 as the WebProfileBuilder will be installed in the Program Files (x86) folder.</p>
<p>You cannot add this Import statement from within the Visual Studio UI so don&#8217;t try!  Save the project file and re-open it in Visual Studio.  Next, assumming you have added your profile properties in the web.config, build your project.  After building, click the button to show All Files and you should now see the WebProfile.cs or WebProfile.vb file located just under the web.config file in the Solution Explorer.  Right click on the WebProfile file and include it in your project.  You should now be able to access the Profile properties via Profile class.</p>
<p>Hopefully this will help anyone looking to continue using the Profile class with WAP!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kps-fl.com/blog/?feed=rss2&#038;p=17</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Taking the Santa Express!</title>
		<link>http://www.kps-fl.com/blog/?p=11</link>
		<comments>http://www.kps-fl.com/blog/?p=11#comments</comments>
		<pubDate>Fri, 03 Dec 2010 21:06:25 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://kps-fl.com.poppy.arvixe.com/blog/?p=11</guid>
		<description><![CDATA[Tomorrow we are going on the Santa Express!  Check out http://www.royalgorgeroute.com/ for more information.]]></description>
			<content:encoded><![CDATA[<p>Tomorrow we are going on the Santa Express!  Check out <a href="http://www.royalgorgeroute.com/">http://www.royalgorgeroute.com/</a> for more information.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kps-fl.com/blog/?feed=rss2&#038;p=11</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Hosting Company Again!</title>
		<link>http://www.kps-fl.com/blog/?p=8</link>
		<comments>http://www.kps-fl.com/blog/?p=8#comments</comments>
		<pubDate>Fri, 03 Dec 2010 16:16:27 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[Other]]></category>

		<guid isPermaLink="false">http://kps-fl.com.poppy.arvixe.com/blog/?p=8</guid>
		<description><![CDATA[Well, I had to switch hosting companies yet again.  Hopefully this one will be better.  So far so good.  This blog will serve as my personal and professional blog space. Greg]]></description>
			<content:encoded><![CDATA[<p>Well, I had to switch hosting companies yet again.  Hopefully this one will be better.  So far so good.  This blog will serve as my personal and professional blog space.</p>
<p>Greg</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kps-fl.com/blog/?feed=rss2&#038;p=8</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

