<?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>DataBatrix &#187; ASP</title>
	<atom:link href="http://www.databatrix.com/category/asp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.databatrix.com</link>
	<description>The workings of Eric Bridges</description>
	<lastBuildDate>Thu, 01 Dec 2011 23:47:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>.NET Serialization: Binary, SOAP, and XML (VB)</title>
		<link>http://www.databatrix.com/2009/10/net-serialization-binary-soap-and-xml-vb/</link>
		<comments>http://www.databatrix.com/2009/10/net-serialization-binary-soap-and-xml-vb/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 23:43:50 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[.NET 2.0]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Binary]]></category>
		<category><![CDATA[Serialization]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.databatrix.com/?p=227</guid>
		<description><![CDATA[In .NET when you need to shrink an object into a more portable format you have 3 choices.  Binary, SOAP, or XML.  The process of shrinking and expanding the object is called serialization and deserialization.  Each option has it&#8217;s own advantages which I will explain. Binary You can serialize an object into binary format quite [...]]]></description>
			<content:encoded><![CDATA[<p>In .NET when you need to shrink an object into a more portable format you have 3 choices.  Binary, SOAP, or XML.  The process of shrinking and expanding the object is called serialization and deserialization.  Each option has it&#8217;s own advantages which I will explain.</p>
<h2>Binary</h2>
<p>You can serialize an object into binary format quite easily using the .NET Framework.  This is the quickest and smallest way to serialize; however, the binary format can only be deserialized using the same .NET Framework.  This may be a problem for interoperability.  It must be noted that this format will serialize Public and Private members (unlike XML serialization).</p>
<p>The example below shows how to serialize an object called &#8220;newCustomer&#8221;:</p>
<pre class="brush:vb">        Dim newCustomer As Contact = GetSampleContact()

        Using fs As New IO.FileStream(filePathandName &amp; ".bin", IO.FileMode.Create)
            Dim binFormatter As New Runtime.Serialization.Formatters.Binary.BinaryFormatter()
            binFormatter.Serialize(fs, newCustomer)
        End Using</pre>
<p>And here is the reverse to deserialize:</p>
<pre class="brush:vb">        Dim readCustomer As Contact

        Using fs As New IO.FileStream(filePathandName &amp; ".bin", IO.FileMode.Open, IO.FileAccess.Read)
            Dim binFormatter As New Runtime.Serialization.Formatters.Binary.BinaryFormatter()
            readCustomer = CType(binFormatter.Deserialize(fs), Contact)
        End Using</pre>
<h2>SOAP</h2>
<p>SOAP is another method.  This is similar to the binary method except the serialized data is stored in a standardized form (SOAP) which will easily allow interoperability.  Public and Private members are serialized using this method as well.<br />
To serialize:</p>
<pre class="brush:vb">        Dim newCustomer As Contact = GetSampleContact()
        Using fs As New IO.FileStream(filePathandName &amp; "SOAP.xml", IO.FileMode.Create)
            Dim soapFormattter As New Runtime.Serialization.Formatters.Soap.SoapFormatter()
            soapFormattter.Serialize(fs, newCustomer)
        End Using</pre>
<p>And to deserialize:</p>
<pre class="brush:vb">        Dim readCustomer As Contact
        Using fs As New IO.FileStream(filePathandName &amp; "SOAP.xml", IO.FileMode.Open, IO.FileAccess.Read)
            Dim soapFormattter As New Runtime.Serialization.Formatters.Soap.SoapFormatter()
            readCustomer = CType(soapFormattter.Deserialize(fs), Contact)
        End Using</pre>
<h2>XML</h2>
<p>A third choice is using the XMLSerializer class.  This method will only serialize Public properties and members and the object must be marked with the Serializable attribute and contain an empty constructor.  This method of serialization will be smaller in size than the SOAP method since less information is serialized.  Here is an example of such class:</p>
<pre class="brush:vb">     &lt;Serializable()&gt; Class Contact

        Private _FirstName As String
        Public Property FirstName() As String
            Get
                Return _FirstName
            End Get
            Set(ByVal value As String)
                _FirstName = value
            End Set
        End Property

        Private _LastName As String
        Public Property LastName() As String
            Get
                Return _LastName
            End Get
            Set(ByVal value As String)
                _LastName = value
            End Set
        End Property

        Private _MiddleI As String
        Public Property MiddleI() As String
            Get
                Return _MiddleI
            End Get
            Set(ByVal value As String)
                _MiddleI = value
            End Set
        End Property

        Private _PIN As String
        Public WriteOnly Property PIN() As String
            Set(ByVal value As String)
                _PIN = value
            End Set
        End Property

        Sub New()

        End Sub

        Sub New(ByVal fName As String, ByVal middleI As String, ByVal lName As String, ByVal p As String)
            _FirstName = fName
            _MiddleI = middleI
            _LastName = lName
            _PIN = p
        End Sub
    End Class</pre>
<p>Here is how you would serialize using the XMLSerializer:</p>
<pre class="brush:vb">        Dim newCustomer As Contact = GetSampleContact()
        Using fs As New IO.FileStream(filePathandName &amp; ".xml", IO.FileMode.Create)
            Dim xmlFormatter As New Xml.Serialization.XmlSerializer(GetType(Contact))
            xmlFormatter.Serialize(fs, newCustomer)
        End Using</pre>
<p>And to deserialize:</p>
<pre class="brush:vb">        Dim readCustomer As Contact
        Using fs As New IO.FileStream(filePathandName &amp; ".xml", IO.FileMode.Open, IO.FileAccess.Read)
            Dim xmlFormatter As New Xml.Serialization.XmlSerializer(GetType(Contact))
            readCustomer = CType(xmlFormatter.Deserialize(fs), Contact)
        End Using</pre>
<p><img class="alignnone size-full wp-image-232" title="Serialization Demo" src="http://www.databatrix.com/wp-content/uploads/2009/10/Serialization.JPG" alt="Serialization Demo" width="505" height="336" /></p>
<p>You can download a sample serialization demo project that I created to demonstrate: <a title="Serialization Demo Project.zip" href="http://www.databatrix.com/wp-content/uploads/2009/10/SerializationDemo.zip">SerializationDemoProject.zip</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.databatrix.com/2009/10/net-serialization-binary-soap-and-xml-vb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installation Schedule</title>
		<link>http://www.databatrix.com/2009/08/installation-schedule/</link>
		<comments>http://www.databatrix.com/2009/08/installation-schedule/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 22:21:38 +0000</pubDate>
		<dc:creator>Eric</dc:creator>
				<category><![CDATA[ASP]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MS SQL]]></category>
		<category><![CDATA[Web Applications]]></category>

		<guid isPermaLink="false">http://www.databatrix.com/?p=13</guid>
		<description><![CDATA[Background: This is what started it all (at least at my previous employer).&#160; The company I worked for company sells stuff and that stuff has to be installed by a professional installer.&#160; They have a large staff of professional installers.&#160; They have a lot of stuff that needs to be installed.&#160; See where I am [...]]]></description>
			<content:encoded><![CDATA[<h3>Background:</h3>
<p>This is what started it all (at least at my previous employer).&#160; The company I worked for company sells <span style="font-style: italic">stuff</span> and that <span style="font-style: italic">stuff</span> has to be installed by a professional installer.&#160; They have a large staff of professional installers.&#160; They have a lot of <span style="font-style: italic">stuff</span> that needs to be installed.&#160; See where I am getting?&#160; Before I started, this information was stored in a Excel spreadsheet, which did the job until they started growing.&#160; Then it was moved to an Access database, which was much better; however, not everyone knows how to use Access, so a basic web interface to the database was created in FrontPage to update the rows of data.&#160; Each row in the table was a day and each row had a column for every installer.</p>
<h3>Problem:</h3>
<p>This was functional, however as installers were added and new column had to be added to the Access database.&#160; Also the FrontPage site had to be updated to account for the added column.&#160; The good thing about FrontPage was that it appears simple because it hides a bunch of code behind the scenes, the bad thing is that if something goes wrong (like your computer crashes while updating the site) it becomes a real nightmare to get everything back up and running.</p>
<h3>Solution:</h3>
<p>The plan was to create a fully database driven installation calendar.&#160; One that could be updated from within the application itself.&#160; Instead of having a list of days and putting a installation on each day, we would have a list of jobs and add installers.&#160; This makes it easier to use since jobs often spanned across multiple days.</p>
<h3>Result:</h3>
<p><a href="http://www.databatrix.com/wp-content/uploads/2009/08/Install_Calendar11.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Install_Calendar1" border="0" alt="Install_Calendar1" src="http://www.databatrix.com/wp-content/uploads/2009/08/Install_Calendar1_thumb.png" width="260" height="169" /></a>Fig. 1</p>
<p><a href="http://www.databatrix.com/wp-content/uploads/2009/08/Install_Calendar21.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Install_Calendar2" border="0" alt="Install_Calendar2" src="http://www.databatrix.com/wp-content/uploads/2009/08/Install_Calendar2_thumb.png" width="260" height="173" /></a>Fig. 2</p>
<p><a href="http://www.databatrix.com/wp-content/uploads/2009/08/Install_Calendar31.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Install_Calendar3" border="0" alt="Install_Calendar3" src="http://www.databatrix.com/wp-content/uploads/2009/08/Install_Calendar3_thumb.png" width="260" height="170" /></a>Fig. 3</p>
<p>I created a web site that used ASP (Classic ASP, not .NET) and a MSDE database.&#160; The hard part for me on this project was drawing out a calendar dynamically and &quot;putting stuff&quot; on it.&#160; How was that going to look?&#160; How should it look?&#160; Fig. 1 shows the result.&#160; The calendar is shown on the left and jobs that are shown in the current view are shown on the right.&#160; Fig. 2 shows the detail view of a job.&#160; This is where installers could be added to a selected job along with a few other functions.&#160; Fig. 3 shows the print view.&#160; This was helpful when trying to coordinate the jobs.&#160; This was another painful page to write because of the layout.&#160; The only way I could get the data in the format I needed for the page was to do lots of sub-queries.&#160; One for each day and installer, this made the process time for this particular page several seconds!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.databatrix.com/2009/08/installation-schedule/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

