<?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/"
	>

<channel>
	<title>madhubaabu@yahoo.com</title>
	<atom:link href="http://madhubaabu.blog.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://madhubaabu.blog.com</link>
	<description></description>
	<pubDate>Wed, 21 May 2008 17:08:39 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Design Patterns Series - part 1</title>
		<link>http://madhubaabu.blog.com/2008/05/21/design-patterns-series-part-1/</link>
		<comments>http://madhubaabu.blog.com/2008/05/21/design-patterns-series-part-1/#comments</comments>
		<pubDate>Wed, 21 May 2008 17:08:39 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[Design Patterns]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[<strong><font color="#0000FF">What is Design Patterns :<br /></font></strong> Design patterns are recurring solutions to software design problems you find again and again in real-world application development. It is a proven solution for a specific problem in specific context. There are lot of design patterens in world. Here i am going to discuss GOF(Gang of Four) design patterens.<br />
<br />
<strong><font color="#0000FF">Types of Design Patterns:<br /></font></strong> I. Creational<br />
II. Structural<br />
III. Behavioral<br />
<br />
<strong><font color="#FF0000"><font color="#0000FF">I. Creational Patterns:</font><br /></font><em>1. Abstract Factory -</em></strong> Provide an interface for creating families of related or dependent objects without specifying their concrete classes.<br />
<br />
<strong><em>2. Builder -</em></strong> Separate the construction of a complex object from its representation so that the same construction process can create different representations.<br />
<br />
<strong><em>3. Factory Method -</em></strong> Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.<br />
<br />
<strong><em>4. Prototype -</em></strong> Specify the kind of objects to create using a prototypical instance, and create new objects by copying this prototype.<br />
<br />
<strong><em>5. Singleton -</em></strong> Ensure a class has only one instance and provide a global point of access to it.<br />
<br />
<font color="#0000FF"><strong>II. Structural&#160;Patterns:<br /></strong></font><font color="#000000"><strong><em>1. Adapter -</em></strong> Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.<br />
<br />
<strong><em>2. Bridge -</em></strong> Decouple an abstraction from its implementation so that the two can vary independently.<br />
<br />
<strong><em>3. Composite -</em></strong> Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.<br />
<br />
<strong><em>4. Decorator -</em></strong> Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.<br />
<br />
<strong><em>5. Facade -</em></strong> Provide a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to use.<br />
<br />
<strong><em>6. FlyWeight -</em></strong> Use sharing to support large numbers of fine-grained objects efficiently.<br />
<br />
<strong><em>7. Proxy -</em></strong> Provide a surrogate or placeholder for another object to control access to it.<br />
<br />
<strong><font color="#0000FF">III. Behavioral&#160;Patterns:</font><br />
<em>1. Chain of Resp -</em></strong> Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.<br />
<br />
<strong><em>2. Command -</em></strong> Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.<br />
<br />
<strong><em>3. Interpreter -</em></strong> Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.<br />
<br />
<strong><em>4. Iterator -</em></strong> Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.<br />
<br />
<strong><em>5. Mediator -</em></strong> Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.<br />
<br />
<strong><em>6. Memento -</em></strong> Without violating encapsulation, capture and externalize an object's internal state so that the object can be restored to this state later.<br />
<br />
<strong><em>7. Observer -</em></strong> Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.<br />
<br />
<strong><em>8. State -</em></strong>Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.<br />
<br />
<strong><em>9. Strategy -&#160;</em></strong>Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.<br />
<br />
<strong><em>10. Template Method -</em></strong> Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.<br />
<br />
<strong><em>11. Visitor -</em></strong> Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates.<br />
<br /></font>
]]></description>
			<content:encoded><![CDATA[<div><strong><font color="#0000FF">What is Design Patterns :<br /></font></strong> Design patterns are recurring solutions to software design problems you find again and again in real-world application development. It is a proven solution for a specific problem in specific context. There are lot of design patterens in world. Here i am going to discuss GOF(Gang of Four) design patterens.</p>
<p><strong><font color="#0000FF">Types of Design Patterns:<br /></font></strong> I. Creational<br />
II. Structural<br />
III. Behavioral</p>
<p><strong><font color="#FF0000"><font color="#0000FF">I. Creational Patterns:</font><br /></font><em>1. Abstract Factory -</em></strong> Provide an interface for creating families of related or dependent objects without specifying their concrete classes.</p>
<p><strong><em>2. Builder -</em></strong> Separate the construction of a complex object from its representation so that the same construction process can create different representations.</p>
<p><strong><em>3. Factory Method -</em></strong> Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.</p>
<p><strong><em>4. Prototype -</em></strong> Specify the kind of objects to create using a prototypical instance, and create new objects by copying this prototype.</p>
<p><strong><em>5. Singleton -</em></strong> Ensure a class has only one instance and provide a global point of access to it.</p>
<p><font color="#0000FF"><strong>II. Structural&#160;Patterns:<br /></strong></font><font color="#000000"><strong><em>1. Adapter -</em></strong> Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn&#8217;t otherwise because of incompatible interfaces.</p>
<p><strong><em>2. Bridge -</em></strong> Decouple an abstraction from its implementation so that the two can vary independently.</p>
<p><strong><em>3. Composite -</em></strong> Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.</p>
<p><strong><em>4. Decorator -</em></strong> Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.</p>
<p><strong><em>5. Facade -</em></strong> Provide a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to use.</p>
<p><strong><em>6. FlyWeight -</em></strong> Use sharing to support large numbers of fine-grained objects efficiently.</p>
<p><strong><em>7. Proxy -</em></strong> Provide a surrogate or placeholder for another object to control access to it.</p>
<p><strong><font color="#0000FF">III. Behavioral&#160;Patterns:</font><br />
<em>1. Chain of Resp -</em></strong> Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.</p>
<p><strong><em>2. Command -</em></strong> Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.</p>
<p><strong><em>3. Interpreter -</em></strong> Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.</p>
<p><strong><em>4. Iterator -</em></strong> Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.</p>
<p><strong><em>5. Mediator -</em></strong> Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.</p>
<p><strong><em>6. Memento -</em></strong> Without violating encapsulation, capture and externalize an object&#8217;s internal state so that the object can be restored to this state later.</p>
<p><strong><em>7. Observer -</em></strong> Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.</p>
<p><strong><em>8. State -</em></strong>Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.</p>
<p><strong><em>9. Strategy -&#160;</em></strong>Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.</p>
<p><strong><em>10. Template Method -</em></strong> Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm&#8217;s structure.</p>
<p><strong><em>11. Visitor -</em></strong> Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates.</p>
<p></font>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://madhubaabu.blog.com/2008/05/21/design-patterns-series-part-1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>object class</title>
		<link>http://madhubaabu.blog.com/2008/05/13/object-class/</link>
		<comments>http://madhubaabu.blog.com/2008/05/13/object-class/#comments</comments>
		<pubDate>Tue, 13 May 2008 16:26:06 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[<strong>object class:</strong> Supports all classes in the .NET Framework class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all classes in the .NET Framework; it is the root of the type hierarchy.<br />
<br />
<strong>Members and Methods:<br /></strong>Equals<br />
Finalize<br />
GetHashCode<br />
GetType<br />
ReferenceEquals<br />
ToString<br />
]]></description>
			<content:encoded><![CDATA[<div><strong>object class:</strong> Supports all classes in the .NET Framework class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all classes in the .NET Framework; it is the root of the type hierarchy.</p>
<p><strong>Members and Methods:<br /></strong>Equals<br />
Finalize<br />
GetHashCode<br />
GetType<br />
ReferenceEquals<br />
ToString
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://madhubaabu.blog.com/2008/05/13/object-class/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Self Join - Sql server</title>
		<link>http://madhubaabu.blog.com/2008/05/13/self-join-sql-server/</link>
		<comments>http://madhubaabu.blog.com/2008/05/13/self-join-sql-server/#comments</comments>
		<pubDate>Tue, 13 May 2008 14:11:33 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[SQL Server 2005]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[<span style="font-size: 11pt; font-family: Arial"><font face="georgia,palatino"><font size="2"><strong>Self-joins :</strong> A self-join is a query in which a table is joined&#160; to itself.<span>&#160;</span> Self-joins are used to compare values in a column with other values in the <span style="font-style: italic">same column in the same table<br />
<br />
<font color="#0000FF"><strong>Example:</strong>&#160;</font> <font color="#000000">In this example i am tring to insert data into Employee table with emp id, manager id. Manager id referes same tables emplid. Finally by using innerjoin i wanted to get data with manager name rather than manager id.<br /></font><br />
<strong>1. Create table<br /></strong> <font size="2" color="#0000FF">CREATE</font> <font size="2" color="#0000FF">TABLE</font> <font size="2">dbo</font><font size="2" color="#808080">.</font><font size="2">Employee</font> </span></font></font></span>
<p><span style="font-size: 11pt; font-family: Arial"><font face="georgia,palatino"><font size="2"><font size="2" color="#808080">(</font></font></font></span></p>
<p><span style="font-size: 11pt; font-family: Arial"><font face="georgia,palatino"><font size="2">empId <font size="2" color="#0000FF">int</font> <font size="2" color="#808080">NOT</font> <font size="2" color="#808080">NULL</font> <font size="2" color="#0000FF">IDENTITY</font> <font size="2" color="#808080">(</font><font size="2">1</font><font size="2" color="#808080">,</font> <font size="2">1</font><font size="2" color="#808080">),</font></font></font></span></p>
<p><span style="font-size: 11pt; font-family: Arial"><font face="georgia,palatino"><font size="2">empName <font size="2" color="#0000FF">nvarchar</font><font size="2" color="#808080">(</font><font size="2">50</font><font size="2" color="#808080">)</font> <font size="2" color="#808080">NOT</font> <font size="2" color="#808080">NULL,</font></font></font></span></p>
<p><span style="font-size: 11pt; font-family: Arial"><font face="georgia,palatino"><font size="2">managerId <font size="2" color="#0000FF">int</font> <font size="2" color="#808080">NULL</font></font></font></span></p>
<span style="font-size: 11pt; font-family: Arial"><font face="georgia,palatino"><font size="2" color="#808080">)</font> <font size="2" color="#0000FF">ON</font> <font size="2">[PRIMARY]<br />
<br />
<strong>2. Insert Data into Table</strong><br />
1,Madhu,NULL<br />
2,Bala,1<br />
3,Krishna,1<br />
4,Ram,1<br />
<br />
<strong>3. SQL Query - Self Join</strong><br /></font></font></span>
<p><span style="font-size: 11pt; font-family: Arial"><font face="georgia,palatino"><font size="2"><font size="2" color="#0000FF">select <font size="2">a</font><font size="2" color="#808080">.</font><font size="2">empId</font><font size="2" color="#808080">,</font> <font size="2">a</font><font size="2" color="#808080">.</font><font size="2">empName</font> <font size="2" color="#0000FF">as</font> <font size="2">Employee</font> <font size="2" color="#808080">,</font> <font size="2">b</font><font size="2" color="#808080">.</font><font size="2">empName</font> <font size="2" color="#0000FF">as</font> <font size="2">ManagerName</font></font></font></font></span></p>
<span style="font-size: 11pt; font-family: Arial"><font face="georgia,palatino"><font size="2"><font size="2" color="#0000FF">from</font> <font size="2">Employee a</font><font size="2" color="#808080">,</font> <font size="2">Employee b</font> <font size="2" color="#0000FF">where</font> <font size="2">b</font><font size="2" color="#808080">.</font><font size="2">empId</font><font size="2" color="#808080">=</font><font size="2">a</font><font size="2" color="#808080">.</font><font size="2">managerId</font></font> </font></span>
<p><span style="font-size: 11pt; font-family: Arial"><font face="georgia,palatino"><font size="2"><br />
<strong>4. Output<br /></strong>2,Bala,Madhu<br />
3,Krishna,Madhu<br />
4,Ram,Madhu<br /></font></font></span></p>

]]></description>
			<content:encoded><![CDATA[<div><span style="font-size: 11pt; font-family: Arial"><font face="georgia,palatino"><font size="2"><strong>Self-joins :</strong> A self-join is a query in which a table is joined&#160; to itself.<span>&#160;</span> Self-joins are used to compare values in a column with other values in the <span style="font-style: italic">same column in the same table</p>
<p><font color="#0000FF"><strong>Example:</strong>&#160;</font> <font color="#000000">In this example i am tring to insert data into Employee table with emp id, manager id. Manager id referes same tables emplid. Finally by using innerjoin i wanted to get data with manager name rather than manager id.<br /></font><br />
<strong>1. Create table<br /></strong> <font size="2" color="#0000FF">CREATE</font> <font size="2" color="#0000FF">TABLE</font> <font size="2">dbo</font><font size="2" color="#808080">.</font><font size="2">Employee</font> </span></font></font></span></p>
<p><span style="font-size: 11pt; font-family: Arial"><font face="georgia,palatino"><font size="2"><font size="2" color="#808080">(</font></font></font></span></p>
<p><span style="font-size: 11pt; font-family: Arial"><font face="georgia,palatino"><font size="2">empId <font size="2" color="#0000FF">int</font> <font size="2" color="#808080">NOT</font> <font size="2" color="#808080">NULL</font> <font size="2" color="#0000FF">IDENTITY</font> <font size="2" color="#808080">(</font><font size="2">1</font><font size="2" color="#808080">,</font> <font size="2">1</font><font size="2" color="#808080">),</font></font></font></span></p>
<p><span style="font-size: 11pt; font-family: Arial"><font face="georgia,palatino"><font size="2">empName <font size="2" color="#0000FF">nvarchar</font><font size="2" color="#808080">(</font><font size="2">50</font><font size="2" color="#808080">)</font> <font size="2" color="#808080">NOT</font> <font size="2" color="#808080">NULL,</font></font></font></span></p>
<p><span style="font-size: 11pt; font-family: Arial"><font face="georgia,palatino"><font size="2">managerId <font size="2" color="#0000FF">int</font> <font size="2" color="#808080">NULL</font></font></font></span></p>
<p><span style="font-size: 11pt; font-family: Arial"><font face="georgia,palatino"><font size="2" color="#808080">)</font> <font size="2" color="#0000FF">ON</font> <font size="2">[PRIMARY]</p>
<p><strong>2. Insert Data into Table</strong><br />
1,Madhu,NULL<br />
2,Bala,1<br />
3,Krishna,1<br />
4,Ram,1</p>
<p><strong>3. SQL Query - Self Join</strong><br /></font></font></span></p>
<p><span style="font-size: 11pt; font-family: Arial"><font face="georgia,palatino"><font size="2"><font size="2" color="#0000FF">select <font size="2">a</font><font size="2" color="#808080">.</font><font size="2">empId</font><font size="2" color="#808080">,</font> <font size="2">a</font><font size="2" color="#808080">.</font><font size="2">empName</font> <font size="2" color="#0000FF">as</font> <font size="2">Employee</font> <font size="2" color="#808080">,</font> <font size="2">b</font><font size="2" color="#808080">.</font><font size="2">empName</font> <font size="2" color="#0000FF">as</font> <font size="2">ManagerName</font></font></font></font></span></p>
<p><span style="font-size: 11pt; font-family: Arial"><font face="georgia,palatino"><font size="2"><font size="2" color="#0000FF">from</font> <font size="2">Employee a</font><font size="2" color="#808080">,</font> <font size="2">Employee b</font> <font size="2" color="#0000FF">where</font> <font size="2">b</font><font size="2" color="#808080">.</font><font size="2">empId</font><font size="2" color="#808080">=</font><font size="2">a</font><font size="2" color="#808080">.</font><font size="2">managerId</font></font> </font></span></p>
<p><span style="font-size: 11pt; font-family: Arial"><font face="georgia,palatino"><font size="2"><br />
<strong>4. Output<br /></strong>2,Bala,Madhu<br />
3,Krishna,Madhu<br />
4,Ram,Madhu<br /></font></font></span></p>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://madhubaabu.blog.com/2008/05/13/self-join-sql-server/feed/</wfw:commentRss>
		</item>
		<item>
		<title>enum - most useful functions</title>
		<link>http://madhubaabu.blog.com/2008/04/25/enum-most-useful-functions/</link>
		<comments>http://madhubaabu.blog.com/2008/04/25/enum-most-useful-functions/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 18:58:42 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[enum]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[<br />
When i am doing .NET programming, many times i have get use of common tasks required related to <strong>'enum'</strong>. Then i taught of writing some common functions related to enum reading, parsing, iterating enum etc. Here we go&#160;...<br />
<br />
<strong>What is enum:</strong> enumuration is comprised of a number of named constants.<br />
<br />
<strong>Creating Enumuration :<br /></strong> <font size="2" color="#0000FF">public <font size="2" color="#0000FF">enum</font> <font size="2" color="#2B91AF">UIType<br /></font></font><font size="2">{<br /></font><font size="2">None,<br />
Label,<br />
DropDown,<br />
TextBox,<br />
CheckBox,<br />
ListBox,<br />
DateTimePicker<br />
}<br />
<strong><br />
Convert Enumuration Item to string :<br /></strong><font size="2" color="#2B91AF"><font size="2" color="#0000FF">string <font size="2" color="#000000">itemValue =</font> <font size="2" color="#2B91AF">UIType</font><font size="2"><font color="#000000">.CheckBox.ToString();<br /></font></font></font></font><font size="2"><strong><br />
Convert string to Enumuration instance:<br /></strong></font><font size="2"><font size="2">returnValue = (</font><font size="2" color="#2B91AF">UIType</font><font size="2">)</font><font size="2" color="#2B91AF">Enum</font><font size="2">.Parse(</font><font size="2" color="#0000FF">typeof</font><font size="2">(</font><font size="2" color="#2B91AF">UIType</font><font size="2">), str,</font> <font size="2" color="#0000FF">true</font><font size="2">);<br /></font></font><font size="2"><font size="2" color="#008000"><strong><em><br />
Note:<br /></em></strong>// While parsing enum it throws an ArgumentException if the string is found not to be one of the members of the enum. you must handle it.<br />
<strong><br />
<font color="#000000">Iterating Enum and reading data from Enum:<br /></font></strong><font size="2" color="#0000FF">foreach</font></font></font> <font size="2">(</font><font size="2" color="#0000FF">string</font> <font size="2">s</font> <font size="2" color="#0000FF">in</font> <font size="2" color="#2B91AF">Enum</font><font size="2">.GetNames(</font> <font size="2" color="#0000FF">typeof</font><font size="2">(</font><font size="2" color="#2B91AF">UIType</font><font size="2">)))<br /></font><font size="2">dropdownlist1.Items.Add(s);<br /></font><strong><br />
Convert integer to Enum instance:<br /></strong><font size="2" color="#2B91AF">UIType <font size="2">chkbox=(</font><font size="2" color="#2B91AF">UIType</font><font size="2">)</font><font size="2" color="#2B91AF">Enum</font><font size="2">.ToObject(</font><font size="2" color="#0000FF">typeof</font><font size="2">(</font><font size="2" color="#2B91AF">UIType</font><font size="2">), (</font><font size="2" color="#0000FF">int</font><font size="2">)</font><font size="2" color="#2B91AF">UIType</font><font size="2">.CheckBox);<br />
<br /></font><font size="2">&#160;</font></font></font>
]]></description>
			<content:encoded><![CDATA[<div>
When i am doing .NET programming, many times i have get use of common tasks required related to <strong>&#8216;enum&#8217;</strong>. Then i taught of writing some common functions related to enum reading, parsing, iterating enum etc. Here we go&#160;&#8230;</p>
<p><strong>What is enum:</strong> enumuration is comprised of a number of named constants.</p>
<p><strong>Creating Enumuration :<br /></strong> <font size="2" color="#0000FF">public <font size="2" color="#0000FF">enum</font> <font size="2" color="#2B91AF">UIType<br /></font></font><font size="2">{<br /></font><font size="2">None,<br />
Label,<br />
DropDown,<br />
TextBox,<br />
CheckBox,<br />
ListBox,<br />
DateTimePicker<br />
}<br />
<strong><br />
Convert Enumuration Item to string :<br /></strong><font size="2" color="#2B91AF"><font size="2" color="#0000FF">string <font size="2" color="#000000">itemValue =</font> <font size="2" color="#2B91AF">UIType</font><font size="2"><font color="#000000">.CheckBox.ToString();<br /></font></font></font></font><font size="2"><strong><br />
Convert string to Enumuration instance:<br /></strong></font><font size="2"><font size="2">returnValue = (</font><font size="2" color="#2B91AF">UIType</font><font size="2">)</font><font size="2" color="#2B91AF">Enum</font><font size="2">.Parse(</font><font size="2" color="#0000FF">typeof</font><font size="2">(</font><font size="2" color="#2B91AF">UIType</font><font size="2">), str,</font> <font size="2" color="#0000FF">true</font><font size="2">);<br /></font></font><font size="2"><font size="2" color="#008000"><strong><em><br />
Note:<br /></em></strong>// While parsing enum it throws an ArgumentException if the string is found not to be one of the members of the enum. you must handle it.<br />
<strong><br />
<font color="#000000">Iterating Enum and reading data from Enum:<br /></font></strong><font size="2" color="#0000FF">foreach</font></font></font> <font size="2">(</font><font size="2" color="#0000FF">string</font> <font size="2">s</font> <font size="2" color="#0000FF">in</font> <font size="2" color="#2B91AF">Enum</font><font size="2">.GetNames(</font> <font size="2" color="#0000FF">typeof</font><font size="2">(</font><font size="2" color="#2B91AF">UIType</font><font size="2">)))<br /></font><font size="2">dropdownlist1.Items.Add(s);<br /></font><strong><br />
Convert integer to Enum instance:<br /></strong><font size="2" color="#2B91AF">UIType <font size="2">chkbox=(</font><font size="2" color="#2B91AF">UIType</font><font size="2">)</font><font size="2" color="#2B91AF">Enum</font><font size="2">.ToObject(</font><font size="2" color="#0000FF">typeof</font><font size="2">(</font><font size="2" color="#2B91AF">UIType</font><font size="2">), (</font><font size="2" color="#0000FF">int</font><font size="2">)</font><font size="2" color="#2B91AF">UIType</font><font size="2">.CheckBox);</p>
<p></font><font size="2">&#160;</font></font></font>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://madhubaabu.blog.com/2008/04/25/enum-most-useful-functions/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Maintain SQL Server 2005 DB changes in log table</title>
		<link>http://madhubaabu.blog.com/2008/04/10/maintain-sql-server-2005-db-changes-in-log-table/</link>
		<comments>http://madhubaabu.blog.com/2008/04/10/maintain-sql-server-2005-db-changes-in-log-table/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 13:04:38 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[SQL Server 2005]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[<span style="font-size: 10pt; color: black; line-height: 140%; font-family: Verdana">Maintaining SQL Server DDL command changes in log file is most important and now it becomes very easy in SQL Server 2005 by using <i>EVENTDATA ()</i> function.<br />
<span>&#160;</span><b><br />
EVENTDATA()</b> is a function is provided by SQL Server 2005, It provides</span> <span style="font-size: 10pt; line-height: 140%; font-family: Verdana">Information about an event that fires a DDL trigger is captured by using the EVENTDATA function. This function returns an <b>xml</b> value. The XML schema includes information about the following:<br /></span> <span style="line-height: 140%; font-family: Symbol"><span><font size="2">·</font><span style="font: 7pt 'Times New Roman'">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span></span></span> <span style="line-height: 140%"><font size="2">The time of the event.<br /></font></span><span style="line-height: 140%; font-family: Symbol"><span><font size="2">·</font><span style="font: 7pt 'Times New Roman'">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span></span></span> <span style="line-height: 140%"><font size="2">The System Process ID (SPID) of the connection when the trigger executed.<br /></font></span><span style="line-height: 140%; font-family: Symbol"><span><font size="2">·</font><span style="font: 7pt 'Times New Roman'">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span></span></span> <span style="line-height: 140%"><font size="2">The type of event that fired the trigger.<br />
<br /></font></span><span style="line-height: 140%"><font size="2"><b><span style="color: black"><font color="#0000FF">Steps for implementation of storing DDL log changes in Table<br />
<br /></font></span></b></font></span>
<p style="margin: 0in 0in 0pt 0.25in; text-indent: -0.25in; tab-stops: list .25in" class="MsoNormal"><span style="line-height: 140%"><b><span style="color: black"><span>1.<span style="font: 7pt 'Times New Roman'">&#160;&#160;&#160;&#160;&#160;</span></span></span> <span style="color: black">Create table to store DDL Transactions</span></b></span></p>
<p><span style="color: blue; font-family: 'Courier New'"><br />
&#160;&#160; CREATE</span> <span style="font-family: 'Courier New'"><span style="color: blue">TABLE</span> [dbo]<span style="color: gray">.</span>[DDLLog]<span style="color: gray">(<br /></span></span><span style="font-family: 'Courier New'"><span>&#160;&#160;</span> [logId] [int] <span style="color: blue">IDENTITY</span><span style="color: gray">(</span>1<span style="color: gray">,</span>1<span style="color: gray">)</span> <span style="color: gray">NOT</span> <span style="color: gray">NULL,<br /></span></span><span style="font-family: 'Courier New'"><span>&#160;&#160;</span> [logData] [xml] <span style="color: gray">NOT</span> <span style="color: gray">NULL,<br /></span></span><span style="font-family: 'Courier New'"><span>&#160;&#160;</span> <span style="color: blue">CONSTRAINT</span> [PK_DDLLog] <span style="color: blue">PRIMARY</span> <span style="color: blue">KEY</span> <span style="color: blue">CLUSTERED</span><br /></span> <span style="color: gray; font-family: 'Courier New'">&#160;&#160; (</span><span style="font-family: 'Courier New'">[logId] <span style="color: blue">ASC</span><span style="color: gray">))</span> <span style="color: blue">ON</span> [PRIMARY]<br /></span><span style="color: black"><span><br />
2.<span style="font: 7pt 'Times New Roman'">&#160;&#160;&#160;&#160;&#160;</span></span></span> <span style="color: black">Create Trigger to fetch DDL commands info and store in DDLLog table<span>&#160;&#160;<br /></span></span> <span style="color: blue; font-family: 'Courier New'"><br />
&#160;&#160; CREATE</span> <span style="font-family: 'Courier New'"><span style="color: blue">TRIGGER</span> [Trig_DDLLog]<br /></span><span style="color: blue; font-family: 'Courier New'">&#160;&#160; ON</span> <span style="font-family: 'Courier New'"><span style="color: blue">DATABASE FOR</span> DDL_DATABASE_LEVEL_EVENTS<br /></span> <span style="color: blue; font-family: 'Courier New'">&#160;&#160; AS<br /></span><span style="color: blue; font-family: 'Courier New'">&#160;&#160; INSERT</span> <span style="font-family: 'Courier New'"><span style="color: blue">INTO</span> dbo<span style="color: gray">.</span>DDLLog<span style="color: gray">(</span>logData<span style="color: gray">)<br /></span></span><span style="color: blue; font-family: 'Courier New'">&#160;&#160; SELECT</span> <span style="font-family: 'Courier New'">EVENTDATA<span style="color: gray">()<br /></span></span><span style="font-family: 'Courier New'">&#160;&#160; GO<br /></span><span style="color: blue; font-family: 'Courier New'">&#160;&#160; ENABLE</span> <span style="font-family: 'Courier New'"><span style="color: blue">TRIGGER</span> [Trig_DDLLog] <span style="color: blue">ON</span> <span style="color: blue">DATABASE<br /></span></span><span><span><br />
3.<span style="font: 7pt 'Times New Roman'">&#160;&#160;&#160;&#160;&#160;</span></span></span> Create a test table to check&#160;<br />
<br />
<span style="color: blue; font-family: 'Courier New'">&#160;&#160; create</span> <span style="font-family: 'Courier New'"><span style="color: blue">table</span> testTable <span style="color: gray">(</span>id <span style="color: blue">int</span><span style="color: gray">,</span> description <span style="color: blue">varchar</span><span style="color: gray">(</span>100<span style="color: gray">))<br /></span></span><span><span><br />
4.<span style="font: 7pt 'Times New Roman'">&#160;&#160;&#160;&#160;&#160;</span></span></span> Watch DDLLog table for log entry …it is available in XML format like below.<br />
<span style="color: blue; font-family: 'Courier New'"><br />
&#60;</span><span style="color: #a31515; font-family: 'Courier New'">EVENT_INSTANCE</span><span style="color: blue; font-family: 'Courier New'">&#62;<br /></span><span style="color: blue; font-family: 'Courier New'">&#60;</span><span style="color: #a31515; font-family: 'Courier New'">EventType</span><span style="color: blue; font-family: 'Courier New'">&#62;</span><span style="font-family: 'Courier New'">CREATE_TABLE<span style="color: blue"><span style="color: #a31515">EventType</span><span style="color: blue">&#62;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &#60;</span><span style="color: #a31515; font-family: 'Courier New'">PostTime</span><span style="color: blue; font-family: 'Courier New'">&#62;</span><span style="font-family: 'Courier New'">2008-04-10T11:48:08.463<span style="color: blue"><span style="color: #a31515">PostTime</span><span style="color: blue">&#62;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &#60;</span><span style="color: #a31515; font-family: 'Courier New'">SPID</span><span style="color: blue; font-family: 'Courier New'">&#62;</span><span style="font-family: 'Courier New'">53<span style="color: blue"><span style="color: #a31515">SPID</span><span style="color: blue">&#62;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &#60;</span><span style="color: #a31515; font-family: 'Courier New'">ServerName</span><span style="color: blue; font-family: 'Courier New'">&#62;</span><span style="font-family: 'Courier New'">BSIAP021<span style="color: blue"><span style="color: #a31515">ServerName</span><span style="color: blue">&#62;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &#60;</span><span style="color: #a31515; font-family: 'Courier New'">LoginName</span><span style="color: blue; font-family: 'Courier New'">&#62;</span><span style="font-family: 'Courier New'">sa<span style="color: blue"><span style="color: #a31515">LoginName</span><span style="color: blue">&#62;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &#60;</span><span style="color: #a31515; font-family: 'Courier New'">UserName</span><span style="color: blue; font-family: 'Courier New'">&#62;</span><span style="font-family: 'Courier New'">dbo<span style="color: blue"><span style="color: #a31515">UserName</span><span style="color: blue">&#62;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &#60;</span><span style="color: #a31515; font-family: 'Courier New'">DatabaseName</span><span style="color: blue; font-family: 'Courier New'">&#62;</span><span style="font-family: 'Courier New'">AdventureWorks<span style="color: blue"><span style="color: #a31515">DatabaseName</span><span style="color: blue">&#62;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &#60;</span><span style="color: #a31515; font-family: 'Courier New'">SchemaName</span><span style="color: blue; font-family: 'Courier New'">&#62;</span><span style="font-family: 'Courier New'">dbo<span style="color: blue"><span style="color: #a31515">SchemaName</span><span style="color: blue">&#62;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &#60;</span><span style="color: #a31515; font-family: 'Courier New'">ObjectName</span><span style="color: blue; font-family: 'Courier New'">&#62;</span><span style="font-family: 'Courier New'">testTable<span style="color: blue"><span style="color: #a31515">ObjectName</span><span style="color: blue">&#62;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &#60;</span><span style="color: #a31515; font-family: 'Courier New'">ObjectType</span><span style="color: blue; font-family: 'Courier New'">&#62;</span><span style="font-family: 'Courier New'">TABLE<span style="color: blue"><span style="color: #a31515">ObjectType</span><span style="color: blue">&#62;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &#60;</span><span style="color: #a31515; font-family: 'Courier New'">TSQLCommand</span><span style="color: blue; font-family: 'Courier New'">&#62;<br /></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> &#60;</span><span style="color: #a31515; font-family: 'Courier New'">SetOptions</span> <span style="color: red; font-family: 'Courier New'">ANSI_NULLS</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">"<span style="color: blue">ON</span>" <span style="color: red">ANSI_NULL_DEFAULT</span><span style="color: blue">=</span>"<span style="color: blue">ON</span>" <span style="color: blue"><br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span></span> <span style="color: red; font-family: 'Courier New'">ANSI_PADDING</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">"<span style="color: blue">ON</span>" <span style="color: red">QUOTED_IDENTIFIER</span><span style="color: blue">=</span>"<span style="color: blue">ON</span>" <span style="color: red">ENCRYPTED</span><span style="color: blue">=</span>"<span style="color: blue">FALSE</span>" <span style="color: blue"><br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> /&#62;<br /></span><span style="color: blue; font-family: 'Courier New'">&#60;</span><span style="color: #a31515; font-family: 'Courier New'">CommandText</span><span style="color: blue; font-family: 'Courier New'">&#62;</span><span style="font-family: 'Courier New'">create table testTable (id int, description varchar(100))<br /></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> <span style="color: #a31515; font-family: 'Courier New'">CommandText</span><span style="color: blue; font-family: 'Courier New'">&#62;<br /></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> <span style="color: #a31515; font-family: 'Courier New'">TSQLCommand</span><span style="color: blue; font-family: 'Courier New'">&#62;<br /></span><span style="color: blue; font-family: 'Courier New'"><span style="color: #a31515; font-family: 'Courier New'">EVENT_INSTANCE</span><span style="color: blue; font-family: 'Courier New'">&#62;<br />
<br /></span>References: <a href="http://technet.microsoft.com/en-us/library/ms187909.aspx"><font color="#800080">http://technet.microsoft.com/en-us/library/ms187909.aspx</font></a><br />
<i><br />
Now it is so simple to maintain SQL Server DDL changes log&#160;<br />
<br /></i>&#160;</span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<div style="text-align: center">*** END ***<br />
<br /></div>

]]></description>
			<content:encoded><![CDATA[<div><span style="font-size: 10pt; color: black; line-height: 140%; font-family: Verdana">Maintaining SQL Server DDL command changes in log file is most important and now it becomes very easy in SQL Server 2005 by using <i>EVENTDATA ()</i> function.<br />
<span>&#160;</span><b><br />
EVENTDATA()</b> is a function is provided by SQL Server 2005, It provides</span> <span style="font-size: 10pt; line-height: 140%; font-family: Verdana">Information about an event that fires a DDL trigger is captured by using the EVENTDATA function. This function returns an <b>xml</b> value. The XML schema includes information about the following:<br /></span> <span style="line-height: 140%; font-family: Symbol"><span><font size="2">·</font><span style="font: 7pt 'Times New Roman'">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span></span></span> <span style="line-height: 140%"><font size="2">The time of the event.<br /></font></span><span style="line-height: 140%; font-family: Symbol"><span><font size="2">·</font><span style="font: 7pt 'Times New Roman'">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span></span></span> <span style="line-height: 140%"><font size="2">The System Process ID (SPID) of the connection when the trigger executed.<br /></font></span><span style="line-height: 140%; font-family: Symbol"><span><font size="2">·</font><span style="font: 7pt 'Times New Roman'">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span></span></span> <span style="line-height: 140%"><font size="2">The type of event that fired the trigger.</p>
<p></font></span><span style="line-height: 140%"><font size="2"><b><span style="color: black"><font color="#0000FF">Steps for implementation of storing DDL log changes in Table</p>
<p></font></span></b></font></span></p>
<p style="margin: 0in 0in 0pt 0.25in; text-indent: -0.25in; tab-stops: list .25in" class="MsoNormal"><span style="line-height: 140%"><b><span style="color: black"><span>1.<span style="font: 7pt 'Times New Roman'">&#160;&#160;&#160;&#160;&#160;</span></span></span> <span style="color: black">Create table to store DDL Transactions</span></b></span></p>
<p><span style="color: blue; font-family: 'Courier New'"><br />
&#160;&#160; CREATE</span> <span style="font-family: 'Courier New'"><span style="color: blue">TABLE</span> [dbo]<span style="color: gray">.</span>[DDLLog]<span style="color: gray">(<br /></span></span><span style="font-family: 'Courier New'"><span>&#160;&#160;</span> [logId] [int] <span style="color: blue">IDENTITY</span><span style="color: gray">(</span>1<span style="color: gray">,</span>1<span style="color: gray">)</span> <span style="color: gray">NOT</span> <span style="color: gray">NULL,<br /></span></span><span style="font-family: 'Courier New'"><span>&#160;&#160;</span> [logData] [xml] <span style="color: gray">NOT</span> <span style="color: gray">NULL,<br /></span></span><span style="font-family: 'Courier New'"><span>&#160;&#160;</span> <span style="color: blue">CONSTRAINT</span> [PK_DDLLog] <span style="color: blue">PRIMARY</span> <span style="color: blue">KEY</span> <span style="color: blue">CLUSTERED</span><br /></span> <span style="color: gray; font-family: 'Courier New'">&#160;&#160; (</span><span style="font-family: 'Courier New'">[logId] <span style="color: blue">ASC</span><span style="color: gray">))</span> <span style="color: blue">ON</span> [PRIMARY]<br /></span><span style="color: black"><span><br />
2.<span style="font: 7pt 'Times New Roman'">&#160;&#160;&#160;&#160;&#160;</span></span></span> <span style="color: black">Create Trigger to fetch DDL commands info and store in DDLLog table<span>&#160;&#160;<br /></span></span> <span style="color: blue; font-family: 'Courier New'"><br />
&#160;&#160; CREATE</span> <span style="font-family: 'Courier New'"><span style="color: blue">TRIGGER</span> [Trig_DDLLog]<br /></span><span style="color: blue; font-family: 'Courier New'">&#160;&#160; ON</span> <span style="font-family: 'Courier New'"><span style="color: blue">DATABASE FOR</span> DDL_DATABASE_LEVEL_EVENTS<br /></span> <span style="color: blue; font-family: 'Courier New'">&#160;&#160; AS<br /></span><span style="color: blue; font-family: 'Courier New'">&#160;&#160; INSERT</span> <span style="font-family: 'Courier New'"><span style="color: blue">INTO</span> dbo<span style="color: gray">.</span>DDLLog<span style="color: gray">(</span>logData<span style="color: gray">)<br /></span></span><span style="color: blue; font-family: 'Courier New'">&#160;&#160; SELECT</span> <span style="font-family: 'Courier New'">EVENTDATA<span style="color: gray">()<br /></span></span><span style="font-family: 'Courier New'">&#160;&#160; GO<br /></span><span style="color: blue; font-family: 'Courier New'">&#160;&#160; ENABLE</span> <span style="font-family: 'Courier New'"><span style="color: blue">TRIGGER</span> [Trig_DDLLog] <span style="color: blue">ON</span> <span style="color: blue">DATABASE<br /></span></span><span><span><br />
3.<span style="font: 7pt 'Times New Roman'">&#160;&#160;&#160;&#160;&#160;</span></span></span> Create a test table to check&#160;</p>
<p><span style="color: blue; font-family: 'Courier New'">&#160;&#160; create</span> <span style="font-family: 'Courier New'"><span style="color: blue">table</span> testTable <span style="color: gray">(</span>id <span style="color: blue">int</span><span style="color: gray">,</span> description <span style="color: blue">varchar</span><span style="color: gray">(</span>100<span style="color: gray">))<br /></span></span><span><span><br />
4.<span style="font: 7pt 'Times New Roman'">&#160;&#160;&#160;&#160;&#160;</span></span></span> Watch DDLLog table for log entry …it is available in XML format like below.<br />
<span style="color: blue; font-family: 'Courier New'"><br />
&lt;</span><span style="color: #a31515; font-family: 'Courier New'">EVENT_INSTANCE</span><span style="color: blue; font-family: 'Courier New'">&gt;<br /></span><span style="color: blue; font-family: 'Courier New'">&lt;</span><span style="color: #a31515; font-family: 'Courier New'">EventType</span><span style="color: blue; font-family: 'Courier New'">&gt;</span><span style="font-family: 'Courier New'">CREATE_TABLE<span style="color: blue"><span style="color: #a31515">EventType</span><span style="color: blue">&gt;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &lt;</span><span style="color: #a31515; font-family: 'Courier New'">PostTime</span><span style="color: blue; font-family: 'Courier New'">&gt;</span><span style="font-family: 'Courier New'">2008-04-10T11:48:08.463<span style="color: blue"><span style="color: #a31515">PostTime</span><span style="color: blue">&gt;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &lt;</span><span style="color: #a31515; font-family: 'Courier New'">SPID</span><span style="color: blue; font-family: 'Courier New'">&gt;</span><span style="font-family: 'Courier New'">53<span style="color: blue"><span style="color: #a31515">SPID</span><span style="color: blue">&gt;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &lt;</span><span style="color: #a31515; font-family: 'Courier New'">ServerName</span><span style="color: blue; font-family: 'Courier New'">&gt;</span><span style="font-family: 'Courier New'">BSIAP021<span style="color: blue"><span style="color: #a31515">ServerName</span><span style="color: blue">&gt;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &lt;</span><span style="color: #a31515; font-family: 'Courier New'">LoginName</span><span style="color: blue; font-family: 'Courier New'">&gt;</span><span style="font-family: 'Courier New'">sa<span style="color: blue"><span style="color: #a31515">LoginName</span><span style="color: blue">&gt;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &lt;</span><span style="color: #a31515; font-family: 'Courier New'">UserName</span><span style="color: blue; font-family: 'Courier New'">&gt;</span><span style="font-family: 'Courier New'">dbo<span style="color: blue"><span style="color: #a31515">UserName</span><span style="color: blue">&gt;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &lt;</span><span style="color: #a31515; font-family: 'Courier New'">DatabaseName</span><span style="color: blue; font-family: 'Courier New'">&gt;</span><span style="font-family: 'Courier New'">AdventureWorks<span style="color: blue"><span style="color: #a31515">DatabaseName</span><span style="color: blue">&gt;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &lt;</span><span style="color: #a31515; font-family: 'Courier New'">SchemaName</span><span style="color: blue; font-family: 'Courier New'">&gt;</span><span style="font-family: 'Courier New'">dbo<span style="color: blue"><span style="color: #a31515">SchemaName</span><span style="color: blue">&gt;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &lt;</span><span style="color: #a31515; font-family: 'Courier New'">ObjectName</span><span style="color: blue; font-family: 'Courier New'">&gt;</span><span style="font-family: 'Courier New'">testTable<span style="color: blue"><span style="color: #a31515">ObjectName</span><span style="color: blue">&gt;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &lt;</span><span style="color: #a31515; font-family: 'Courier New'">ObjectType</span><span style="color: blue; font-family: 'Courier New'">&gt;</span><span style="font-family: 'Courier New'">TABLE<span style="color: blue"><span style="color: #a31515">ObjectType</span><span style="color: blue">&gt;<br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> &lt;</span><span style="color: #a31515; font-family: 'Courier New'">TSQLCommand</span><span style="color: blue; font-family: 'Courier New'">&gt;<br /></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> &lt;</span><span style="color: #a31515; font-family: 'Courier New'">SetOptions</span> <span style="color: red; font-family: 'Courier New'">ANSI_NULLS</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">&#8220;<span style="color: blue">ON</span>&#8221; <span style="color: red">ANSI_NULL_DEFAULT</span><span style="color: blue">=</span>&#8220;<span style="color: blue">ON</span>&#8221; <span style="color: blue"><br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span></span> <span style="color: red; font-family: 'Courier New'">ANSI_PADDING</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">&#8220;<span style="color: blue">ON</span>&#8221; <span style="color: red">QUOTED_IDENTIFIER</span><span style="color: blue">=</span>&#8220;<span style="color: blue">ON</span>&#8221; <span style="color: red">ENCRYPTED</span><span style="color: blue">=</span>&#8220;<span style="color: blue">FALSE</span>&#8221; <span style="color: blue"><br /></span></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> /&gt;<br /></span><span style="color: blue; font-family: 'Courier New'">&lt;</span><span style="color: #a31515; font-family: 'Courier New'">CommandText</span><span style="color: blue; font-family: 'Courier New'">&gt;</span><span style="font-family: 'Courier New'">create table testTable (id int, description varchar(100))<br /></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> <span style="color: #a31515; font-family: 'Courier New'">CommandText</span><span style="color: blue; font-family: 'Courier New'">&gt;<br /></span><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;</span> <span style="color: #a31515; font-family: 'Courier New'">TSQLCommand</span><span style="color: blue; font-family: 'Courier New'">&gt;<br /></span><span style="color: blue; font-family: 'Courier New'"><span style="color: #a31515; font-family: 'Courier New'">EVENT_INSTANCE</span><span style="color: blue; font-family: 'Courier New'">&gt;</p>
<p></span>References: <a href="http://technet.microsoft.com/en-us/library/ms187909.aspx"><font color="#800080">http://technet.microsoft.com/en-us/library/ms187909.aspx</font></a><br />
<i><br />
Now it is so simple to maintain SQL Server DDL changes log&#160;</p>
<p></i>&#160;</span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<div style="text-align: center">*** END ***</p>
</div>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://madhubaabu.blog.com/2008/04/10/maintain-sql-server-2005-db-changes-in-log-table/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Introducing SQL Server 2005 &#8220;Schema&#8221; and usage</title>
		<link>http://madhubaabu.blog.com/2008/04/09/introducing-sql-server-2005-schema-and-usage/</link>
		<comments>http://madhubaabu.blog.com/2008/04/09/introducing-sql-server-2005-schema-and-usage/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 00:00:00 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[SQL Server 2005]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[<p style="margin: 0in 0in 0pt" class="MsoNormal"><font size="2">A <b>schema</b> is nothing more than a named, logical container in which you can create database objects. A new schema is created using the <i>CREATE SCHEMA</i> DDL statement. Beginning in SQL Server 2005, each object belongs to a database schema. A database schema is a distinct namespace that is separate from a database user. Schemas can be created and altered in a database, and users can be granted access to a schema. A schema can be owned by any user, and schema ownership is transferable.<br /></font></p>
<p style="margin: 0in 0in 0pt" class="MsoNormal"><font size="2"><br />
SQL Server 2005 has given us the ability to create schemas independent of the user, and by this we achieve separation of schemas and users. This gives us some considerable advantages:</font></p>
<ol type="1" style="margin-top: 0in">
<li style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><font size="2">The first benefit is the ability to subdivide your database into logic of interest, rather as the Erwin modeling tool lets you create subject areas.</font></li>
<li style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><font size="2">You can provide better security at Schema level.</font></li>
<li style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><font size="2">Dropping database users is greatly simplified; dropping a database user does not require the renaming of objects contained by that user's schema. Thus it is no longer necessary to revise and test applications that refer explicitly to schema-contained objects after dropping the user that created them</font></li>
<li style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><font size="2">Multiple users can share a single default schema for uniform name resolution.</font></li>
<li style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><font size="2">Shared default schemas allow developers to store shared objects in a schema created specifically for a specific application, rather than in the DBO schema</font></li>
<li style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><font size="2">Permissions on schemas and schema-contained objects can be managed with a higher degree of granularity than in earlier releases.</font></li>
<li style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><font size="2">Fully qualified name of object in SQL Server 2000 and earlier looks like<br /></font> <font size="2">[Server].[DatabaseName].[OwnerName].[ObjectName]</font></li>
<li style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><font size="2">SQL Server 2005’s fully qualified name for object looks like below<br /></font> <font size="2">[Server].[DatabaseName].[Schema].[ObjectName]</font></li>
<li style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><font size="2">You can able to transfer Schema ownership</font></li>
</ol>
<p style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><b><font size="2">Creating schema<br /></font></b><font size="2"><span style="color: blue; font-family: 'Courier New'">CREATE</span> <span style="font-family: 'Courier New'"><span style="color: blue">SCHEMA</span> Marketing<br /></span></font><font size="2"><span style="font-family: 'Courier New'">GO<br />
<br /></span></font></p>
<p style="margin: 0in 0in 0pt" class="MsoNormal"><b><font size="2">Adding table object<br /></font></b></p>
<p style="margin: 0in 0in 0pt" class="MsoNormal"><font size="2"><span style="color: blue; font-family: 'Courier New'">CREATE</span> <span style="font-family: 'Courier New'"><span style="color: blue">TABLE</span> Marketing<span style="color: gray">.</span>Leads<br /></span></font></p>
<span style="color: gray; font-family: 'Courier New'"><font size="2">(<br /></font></span><span style="font-family: 'Courier New'"><font size="2"><span>&#160;&#160;&#160;</span> LeadId <span style="color: blue">INT</span><span style="color: gray">,<br /></span></font></span><span style="font-family: 'Courier New'"><font size="2"><span>&#160;&#160;&#160;</span> LeadDescription <span style="color: blue">NVARCHAR</span><span style="color: gray">(</span>50<span style="color: gray">)<br /></span></font></span><span style="color: gray; font-family: 'Courier New'"><font size="2">)<br /></font></span><span style="font-family: 'Courier New'"><font size="2">GO<br />
<br /></font></span>
<p><span style="font-family: 'Courier New'"><font size="2"><br /></font></span></p>
<b><font size="2">Accessing table object<br />
<br /></font></b> <font size="2"><span style="color: blue; font-family: 'Courier New'">SELECT</span> <span style="font-family: 'Courier New'"><span style="color: gray">*</span> <span style="color: blue">FROM</span> Marketing<span style="color: gray">.</span>Leads<br /></span></font><span style="font-size: 10pt; font-family: 'Courier New'">GO<br />
<br /></span><span style="font-size: 10pt; font-family: 'Courier New'"><b><font face="Verdana">After you have created schemas, your&#160;database looks like below<br />
<br />
<img align="bottom" src="http://amadeo.blog.com/repository/346327/3057301.jpg" /><br /></font></b></span>
<p><span style="font-size: 10pt; font-family: 'Courier New'"><b><font face="Verdana"><br /></font></b></span></p>
<div style="text-align: center"><span style="font-size: 10pt; font-family: 'Courier New'"><b><font face="Verdana">*** END ***<br />
<br /></font></b></span></div>

]]></description>
			<content:encoded><![CDATA[<div>
<p style="margin: 0in 0in 0pt" class="MsoNormal"><font size="2">A <b>schema</b> is nothing more than a named, logical container in which you can create database objects. A new schema is created using the <i>CREATE SCHEMA</i> DDL statement. Beginning in SQL Server 2005, each object belongs to a database schema. A database schema is a distinct namespace that is separate from a database user. Schemas can be created and altered in a database, and users can be granted access to a schema. A schema can be owned by any user, and schema ownership is transferable.<br /></font></p>
<p style="margin: 0in 0in 0pt" class="MsoNormal"><font size="2"><br />
SQL Server 2005 has given us the ability to create schemas independent of the user, and by this we achieve separation of schemas and users. This gives us some considerable advantages:</font></p>
<ol type="1" style="margin-top: 0in">
<li style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><font size="2">The first benefit is the ability to subdivide your database into logic of interest, rather as the Erwin modeling tool lets you create subject areas.</font></li>
<li style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><font size="2">You can provide better security at Schema level.</font></li>
<li style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><font size="2">Dropping database users is greatly simplified; dropping a database user does not require the renaming of objects contained by that user&#8217;s schema. Thus it is no longer necessary to revise and test applications that refer explicitly to schema-contained objects after dropping the user that created them</font></li>
<li style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><font size="2">Multiple users can share a single default schema for uniform name resolution.</font></li>
<li style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><font size="2">Shared default schemas allow developers to store shared objects in a schema created specifically for a specific application, rather than in the DBO schema</font></li>
<li style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><font size="2">Permissions on schemas and schema-contained objects can be managed with a higher degree of granularity than in earlier releases.</font></li>
<li style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><font size="2">Fully qualified name of object in SQL Server 2000 and earlier looks like<br /></font> <font size="2">[Server].[DatabaseName].[OwnerName].[ObjectName]</font></li>
<li style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><font size="2">SQL Server 2005’s fully qualified name for object looks like below<br /></font> <font size="2">[Server].[DatabaseName].[Schema].[ObjectName]</font></li>
<li style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><font size="2">You can able to transfer Schema ownership</font></li>
</ol>
<p style="margin: 0in 0in 0pt; tab-stops: list .5in" class="MsoNormal"><b><font size="2">Creating schema<br /></font></b><font size="2"><span style="color: blue; font-family: 'Courier New'">CREATE</span> <span style="font-family: 'Courier New'"><span style="color: blue">SCHEMA</span> Marketing<br /></span></font><font size="2"><span style="font-family: 'Courier New'">GO</p>
<p></span></font></p>
<p style="margin: 0in 0in 0pt" class="MsoNormal"><b><font size="2">Adding table object<br /></font></b></p>
<p style="margin: 0in 0in 0pt" class="MsoNormal"><font size="2"><span style="color: blue; font-family: 'Courier New'">CREATE</span> <span style="font-family: 'Courier New'"><span style="color: blue">TABLE</span> Marketing<span style="color: gray">.</span>Leads<br /></span></font></p>
<p><span style="color: gray; font-family: 'Courier New'"><font size="2">(<br /></font></span><span style="font-family: 'Courier New'"><font size="2"><span>&#160;&#160;&#160;</span> LeadId <span style="color: blue">INT</span><span style="color: gray">,<br /></span></font></span><span style="font-family: 'Courier New'"><font size="2"><span>&#160;&#160;&#160;</span> LeadDescription <span style="color: blue">NVARCHAR</span><span style="color: gray">(</span>50<span style="color: gray">)<br /></span></font></span><span style="color: gray; font-family: 'Courier New'"><font size="2">)<br /></font></span><span style="font-family: 'Courier New'"><font size="2">GO</p>
<p></font></span></p>
<p><span style="font-family: 'Courier New'"><font size="2"><br /></font></span></p>
<p><b><font size="2">Accessing table object</p>
<p></font></b> <font size="2"><span style="color: blue; font-family: 'Courier New'">SELECT</span> <span style="font-family: 'Courier New'"><span style="color: gray">*</span> <span style="color: blue">FROM</span> Marketing<span style="color: gray">.</span>Leads<br /></span></font><span style="font-size: 10pt; font-family: 'Courier New'">GO</p>
<p></span><span style="font-size: 10pt; font-family: 'Courier New'"><b><font face="Verdana">After you have created schemas, your&#160;database looks like below</p>
<p><img align="bottom" src="http://amadeo.blog.com/repository/346327/3057301.jpg" /><br /></font></b></span></p>
<p><span style="font-size: 10pt; font-family: 'Courier New'"><b><font face="Verdana"><br /></font></b></span></p>
<div style="text-align: center"><span style="font-size: 10pt; font-family: 'Courier New'"><b><font face="Verdana">*** END ***</p>
<p></font></b></span></div>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://madhubaabu.blog.com/2008/04/09/introducing-sql-server-2005-schema-and-usage/feed/</wfw:commentRss>
		</item>
		<item>
		<title>creating MSDN-style documentation from .NET assemblies - SandCastle</title>
		<link>http://madhubaabu.blog.com/2008/03/30/creating-msdn-style-documentation-from-net-assemblies-sandcastle/</link>
		<comments>http://madhubaabu.blog.com/2008/03/30/creating-msdn-style-documentation-from-net-assemblies-sandcastle/#comments</comments>
		<pubDate>Sun, 30 Mar 2008 23:15:34 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[Generate html help file]]></category>

		<category><![CDATA[SandCastle]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[<br />
<strong>Introduction:</strong> <strong>Sandcastle</strong> is a command line based tool created by Microsoft, used for creating MSDN-style documentation from .NET assemblies and their associated XML comments files.&#160;<b>Sandcastle Help File Builder</b> is to provide graphical and command line based tools to build a help file in an automated fashion.<br />
<br />
<em>Simple steps to generate help files for your assemblies&#160;<br />
=====================================</em><br />
<strong>I. Softwares to be installed:</strong><br />
SandCastle - <a href="http://www.codeplex.com/Sandcastle">http://www.codeplex.com/Sandcastle</a><br />
SandCstle help file builder - <a href="http://www.codeplex.com/SHFB">http://www.codeplex.com/SHFB</a><br />
<br />
<strong>II. Configuration in Visual studio</strong><br />
Configure Visual studio to generate XML comment file along with assemblies<br />
<p>Project properties -&#62;&#160;Build tab -&#62;&#160;check "XML documentation file"<br />
<a href="http://amadeo.blog.com/repository/346327/3023962.jpg"><img align="center" src="http://amadeo.blog.com/repository/346327/3023962.200.p.tn.jpg" /></a><br />
<br />
<strong>III. Configure SandCastle Help Builder<br /></strong> Create a new project and add your assembly to the project. Once you added assemblyname it appears with xml comment file. It looks like&#160;"MyAssembly.dll, MyAssembly.xml".<br />
<br />
<strong>IV. Finally build help file<br /></strong>In SandCastle Help Builder -&#62; Goto "Documentation" menu&#160;-&#62; Build Project<br />
<br />
Once you build project, It&#160;saves help project file as well once it gets build you will have your html help file.</p>
<div style="text-align: center"><br />
<br />
****END****&#160;</div>
<p><br />
<br />
&#160;</p>

]]></description>
			<content:encoded><![CDATA[<div>
<strong>Introduction:</strong> <strong>Sandcastle</strong> is a command line based tool created by Microsoft, used for creating MSDN-style documentation from .NET assemblies and their associated XML comments files.&#160;<b>Sandcastle Help File Builder</b> is to provide graphical and command line based tools to build a help file in an automated fashion.</p>
<p><em>Simple steps to generate help files for your assemblies&#160;<br />
=====================================</em><br />
<strong>I. Softwares to be installed:</strong><br />
SandCastle - <a href="http://www.codeplex.com/Sandcastle">http://www.codeplex.com/Sandcastle</a><br />
SandCstle help file builder - <a href="http://www.codeplex.com/SHFB">http://www.codeplex.com/SHFB</a></p>
<p><strong>II. Configuration in Visual studio</strong><br />
Configure Visual studio to generate XML comment file along with assemblies</p>
<p>Project properties -&gt;&#160;Build tab -&gt;&#160;check &#8220;XML documentation file&#8221;<br />
<a href="http://amadeo.blog.com/repository/346327/3023962.jpg"><img align="center" src="http://amadeo.blog.com/repository/346327/3023962.200.p.tn.jpg" /></a></p>
<p><strong>III. Configure SandCastle Help Builder<br /></strong> Create a new project and add your assembly to the project. Once you added assemblyname it appears with xml comment file. It looks like&#160;&#8221;MyAssembly.dll, MyAssembly.xml&#8221;.</p>
<p><strong>IV. Finally build help file<br /></strong>In SandCastle Help Builder -&gt; Goto &#8220;Documentation&#8221; menu&#160;-&gt; Build Project</p>
<p>Once you build project, It&#160;saves help project file as well once it gets build you will have your html help file.</p>
<div style="text-align: center">
<p>****END****&#160;</p></div>
<p>&#160;</p>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://madhubaabu.blog.com/2008/03/30/creating-msdn-style-documentation-from-net-assemblies-sandcastle/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SubSonic step by step</title>
		<link>http://madhubaabu.blog.com/2008/03/30/subsonic-step-by-step/</link>
		<comments>http://madhubaabu.blog.com/2008/03/30/subsonic-step-by-step/#comments</comments>
		<pubDate>Sun, 30 Mar 2008 19:45:46 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[SubSonic]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[&#160;&#160;<br />
<br />
<p style="text-align: center"><b><u>SubSonic step by step</u></b></p>
<br />
<p><b>I. SubSonic is a toolset that helps to</b></p>
<ol type="1">
<li>Generate DAL layer</li>
<li>Maintains and Generates SQL Script for DB Versioning</li>
<li>Dynamic Query tool helps to use SQL Server etc without knowing SQL</li>
<li>OR Mapper that extends to views and stored procedures</li>
</ol>
<br />
<p><b>II. Installation</b></p>
<ol type="1">
<li>Download SubSonic @ <a href="http://www.codeplex.com/subsonic/Release/ProjectReleases.aspx?ReleaseId=5636">http://www.codeplex.com/subsonic/Release/ProjectReleases.aspx?ReleaseId=5636</a></li>
<li>Install SubSonic by walking through steps, by default it stores at <i>"Program Files\SubSonic\SubSonic 2.1 Beta 2\SubSonic"</i></li>
</ol>
<p><b>III. Configuring inside Visual Studio 2005/ 2008 to use SubSonic</b></p>
<ol type="1">
<li>Create new Website project<br />
<img align="center" src="http://amadeo.blog.com/repository/346327/3023360.jpg" /><br /></li>
<li>Create another new class library project say ‘NorthWindDAL' and add to solution as shown below (this project is going to act as DAL layer for web project)</li>
</ol>
<br />
<div style="text-align: center"><img src="http://amadeo.blog.com/repository/346327/3023364.jpg" /></div>
<br />
<ol start="3" type="1">
<li>Add application configuration file to ‘NorthWindDAL' class library (<i>app.config)</i></li>
<li>Create folder in NorthWindDAL project to keep all Subsonic generated classes</li>
<li>Add below configuration sections to app.config file of NorthWindDAL project
<ol type="a">
<li>Add configsection</li>
</ol>
</li>
</ol>
<font size="2"><span style="color: blue; font-family: 'Courier New'">&#60;</span><span style="color: #a31515; font-family: 'Courier New'">configSections</span><span style="color: blue; font-family: 'Courier New'">&#62;<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> &#60;</span><span style="color: #a31515; font-family: 'Courier New'">section</span> <span style="color: red; font-family: 'Courier New'">name</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">"<span style="color: blue">SubSonicService</span>"<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> <span>&#160;</span></span><span style="color: red; font-family: 'Courier New'">type</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">"<span style="color: blue">SubSonic.SubSonicSection,SubSonic</span>"<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> <span>&#160;</span></span><span style="color: red; font-family: 'Courier New'">requirePermission</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">"<span style="color: blue">false</span>"<span style="color: blue">/&#62;<br /></span></span></font>
<p style="margin: 0in 0in 0pt 0.75in" class="MsoNormal"><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;</span> &#60;/</span><span style="color: #a31515; font-family: 'Courier New'">configSections</span><span style="color: blue; font-family: 'Courier New'">&#62;</span></font>&#160;</p>
<ol start="2" type="a">
<li>add Connection strings section</li>
</ol>
<font size="2"><span style="color: blue; font-family: 'Courier New'">&#60;</span><span style="color: #a31515; font-family: 'Courier New'">connectionStrings</span><span style="color: blue; font-family: 'Courier New'">&#62;<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'">&#60;</span><span style="color: #a31515; font-family: 'Courier New'">add</span> <span style="color: red; font-family: 'Courier New'">name</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">"<span style="color: blue">NorthWind</span>"<span style="color: blue"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span></span> <span style="color: red">connectionString</span><span style="color: blue">=</span>"<span style="color: blue">Server=yourserverName;Database=dbName;UID=youruserName;PWD=yourPassword;</span>"<span style="color: blue">/&#62;<br /></span></span></font>
<p style="margin: 0in 0in 0pt 0.75in" class="MsoNormal"><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;</span> &#60;/</span><span style="color: #a31515; font-family: 'Courier New'">connectionStrings</span><span style="color: blue; font-family: 'Courier New'">&#62;</span></font>&#160;</p>
<ol start="3" type="a">
<li>add Subsonic service provider</li>
</ol>
<font size="2"><span style="color: blue; font-family: 'Courier New'">&#60;</span><span style="color: #a31515; font-family: 'Courier New'">SubSonicService</span> <span style="color: red; font-family: 'Courier New'">defaultProvider</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">"<span style="color: blue">NorthWind</span>"<span style="color: blue">&#62;<br /></span></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> &#60;</span><span style="color: #a31515; font-family: 'Courier New'">providers</span><span style="color: blue; font-family: 'Courier New'">&#62;<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> &#60;</span><span style="color: #a31515; font-family: 'Courier New'">clear</span><span style="color: blue; font-family: 'Courier New'">/&#62;<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> &#60;</span><span style="color: #a31515; font-family: 'Courier New'">add</span> <span style="color: red; font-family: 'Courier New'">name</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">"<span style="color: blue">NorthWind</span>"<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> <span>&#160;</span></span><span style="color: red; font-family: 'Courier New'">type</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">"<span style="color: blue">SubSonic.SqlDataProvider, SubSonic</span>"<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> <span>&#160;</span></span><span style="color: red; font-family: 'Courier New'">connectionStringName</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">"<span style="color: blue">NorthWind</span>"<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> <span>&#160;</span></span><span style="color: red; font-family: 'Courier New'">generatedNamespace</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">"<span style="color: blue">NorthWind</span>"<span style="color: blue"><span>&#160;</span> /&#62;<br /></span></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> &#60;/</span><span style="color: #a31515; font-family: 'Courier New'">providers</span><span style="color: blue; font-family: 'Courier New'">&#62;<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;</span> &#60;/</span><span style="color: #a31515; font-family: 'Courier New'">SubSonicService</span><span style="color: blue; font-family: 'Courier New'">&#62;<br /></span></font><br />
<ol start="6" type="1">
<li>Goto Bin folder of NorthWindDAL project and give reference to ‘SubSonic.dll' available at <i>"Program Files\SubSonic\SubSonic 2.1 Beta 2\SubSonic"</i></li>
<li>and add reference to System.Web and System.Configuration</li>
</ol>
<br />
<p>IV. Adding SubSonic Commander as external tool in Visual studio</p>
<br />
<p><img align="bottom" src="http://amadeo.blog.com/repository/346327/3023382.jpg" /></p>
<br />
<div style="text-align: center"><img src="http://amadeo.blog.com/repository/346327/3023387.jpg" /></div>
<p>Now you are ready for generate code.</p>
<br />
<p>When you click on External tool ‘SubSonicDAL' , it generates code in specified folder that is ‘NorthWind'</p>
<br />
<p>That's it.....&#160; so simple</p>
<br />
<br />
<br />
]]></description>
			<content:encoded><![CDATA[<div>&#160;&#160;</p>
<p style="text-align: center"><b><u>SubSonic step by step</u></b></p>
<p></p>
<p><b>I. SubSonic is a toolset that helps to</b></p>
<ol type="1">
<li>Generate DAL layer</li>
<li>Maintains and Generates SQL Script for DB Versioning</li>
<li>Dynamic Query tool helps to use SQL Server etc without knowing SQL</li>
<li>OR Mapper that extends to views and stored procedures</li>
</ol>
<p></p>
<p><b>II. Installation</b></p>
<ol type="1">
<li>Download SubSonic @ <a href="http://www.codeplex.com/subsonic/Release/ProjectReleases.aspx?ReleaseId=5636">http://www.codeplex.com/subsonic/Release/ProjectReleases.aspx?ReleaseId=5636</a></li>
<li>Install SubSonic by walking through steps, by default it stores at <i>&#8220;Program Files\SubSonic\SubSonic 2.1 Beta 2\SubSonic&#8221;</i></li>
</ol>
<p><b>III. Configuring inside Visual Studio 2005/ 2008 to use SubSonic</b></p>
<ol type="1">
<li>Create new Website project<br />
<img align="center" src="http://amadeo.blog.com/repository/346327/3023360.jpg" /></li>
<li>Create another new class library project say ‘NorthWindDAL&#8217; and add to solution as shown below (this project is going to act as DAL layer for web project)</li>
</ol>
<p></p>
<div style="text-align: center"><img src="http://amadeo.blog.com/repository/346327/3023364.jpg" /></div>
<p></p>
<ol start="3" type="1">
<li>Add application configuration file to ‘NorthWindDAL&#8217; class library (<i>app.config)</i></li>
<li>Create folder in NorthWindDAL project to keep all Subsonic generated classes</li>
<li>Add below configuration sections to app.config file of NorthWindDAL project
<ol type="a">
<li>Add configsection</li>
</ol>
</li>
</ol>
<p><font size="2"><span style="color: blue; font-family: 'Courier New'">&lt;</span><span style="color: #a31515; font-family: 'Courier New'">configSections</span><span style="color: blue; font-family: 'Courier New'">&gt;<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> &lt;</span><span style="color: #a31515; font-family: 'Courier New'">section</span> <span style="color: red; font-family: 'Courier New'">name</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">&#8220;<span style="color: blue">SubSonicService</span>&#8220;<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> <span>&#160;</span></span><span style="color: red; font-family: 'Courier New'">type</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">&#8220;<span style="color: blue">SubSonic.SubSonicSection,SubSonic</span>&#8220;<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> <span>&#160;</span></span><span style="color: red; font-family: 'Courier New'">requirePermission</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">&#8220;<span style="color: blue">false</span>&#8220;<span style="color: blue">/&gt;<br /></span></span></font></p>
<p style="margin: 0in 0in 0pt 0.75in" class="MsoNormal"><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;</span> &lt;/</span><span style="color: #a31515; font-family: 'Courier New'">configSections</span><span style="color: blue; font-family: 'Courier New'">&gt;</span></font>&#160;</p>
<ol start="2" type="a">
<li>add Connection strings section</li>
</ol>
<p><font size="2"><span style="color: blue; font-family: 'Courier New'">&lt;</span><span style="color: #a31515; font-family: 'Courier New'">connectionStrings</span><span style="color: blue; font-family: 'Courier New'">&gt;<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'">&lt;</span><span style="color: #a31515; font-family: 'Courier New'">add</span> <span style="color: red; font-family: 'Courier New'">name</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">&#8220;<span style="color: blue">NorthWind</span>&#8220;<span style="color: blue"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span></span> <span style="color: red">connectionString</span><span style="color: blue">=</span>&#8220;<span style="color: blue">Server=yourserverName;Database=dbName;UID=youruserName;PWD=yourPassword;</span>&#8220;<span style="color: blue">/&gt;<br /></span></span></font></p>
<p style="margin: 0in 0in 0pt 0.75in" class="MsoNormal"><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;</span> &lt;/</span><span style="color: #a31515; font-family: 'Courier New'">connectionStrings</span><span style="color: blue; font-family: 'Courier New'">&gt;</span></font>&#160;</p>
<ol start="3" type="a">
<li>add Subsonic service provider</li>
</ol>
<p><font size="2"><span style="color: blue; font-family: 'Courier New'">&lt;</span><span style="color: #a31515; font-family: 'Courier New'">SubSonicService</span> <span style="color: red; font-family: 'Courier New'">defaultProvider</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">&#8220;<span style="color: blue">NorthWind</span>&#8220;<span style="color: blue">&gt;<br /></span></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> &lt;</span><span style="color: #a31515; font-family: 'Courier New'">providers</span><span style="color: blue; font-family: 'Courier New'">&gt;<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> &lt;</span><span style="color: #a31515; font-family: 'Courier New'">clear</span><span style="color: blue; font-family: 'Courier New'">/&gt;<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> &lt;</span><span style="color: #a31515; font-family: 'Courier New'">add</span> <span style="color: red; font-family: 'Courier New'">name</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">&#8220;<span style="color: blue">NorthWind</span>&#8220;<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> <span>&#160;</span></span><span style="color: red; font-family: 'Courier New'">type</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">&#8220;<span style="color: blue">SubSonic.SqlDataProvider, SubSonic</span>&#8220;<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> <span>&#160;</span></span><span style="color: red; font-family: 'Courier New'">connectionStringName</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">&#8220;<span style="color: blue">NorthWind</span>&#8220;<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> <span>&#160;</span></span><span style="color: red; font-family: 'Courier New'">generatedNamespace</span><span style="color: blue; font-family: 'Courier New'">=</span><span style="font-family: 'Courier New'">&#8220;<span style="color: blue">NorthWind</span>&#8220;<span style="color: blue"><span>&#160;</span> /&gt;<br /></span></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span> &lt;/</span><span style="color: #a31515; font-family: 'Courier New'">providers</span><span style="color: blue; font-family: 'Courier New'">&gt;<br /></span></font><font size="2"><span style="color: blue; font-family: 'Courier New'"><span>&#160;&#160;</span> &lt;/</span><span style="color: #a31515; font-family: 'Courier New'">SubSonicService</span><span style="color: blue; font-family: 'Courier New'">&gt;<br /></span></font></p>
<ol start="6" type="1">
<li>Goto Bin folder of NorthWindDAL project and give reference to ‘SubSonic.dll&#8217; available at <i>&#8220;Program Files\SubSonic\SubSonic 2.1 Beta 2\SubSonic&#8221;</i></li>
<li>and add reference to System.Web and System.Configuration</li>
</ol>
<p></p>
<p>IV. Adding SubSonic Commander as external tool in Visual studio</p>
<p></p>
<p><img align="bottom" src="http://amadeo.blog.com/repository/346327/3023382.jpg" /></p>
<p></p>
<div style="text-align: center"><img src="http://amadeo.blog.com/repository/346327/3023387.jpg" /></div>
<p>Now you are ready for generate code.</p>
<p></p>
<p>When you click on External tool ‘SubSonicDAL&#8217; , it generates code in specified folder that is ‘NorthWind&#8217;</p>
<p></p>
<p>That&#8217;s it&#8230;..&#160; so simple</p>
<p>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://madhubaabu.blog.com/2008/03/30/subsonic-step-by-step/feed/</wfw:commentRss>
		</item>
		<item>
		<title>.NET 3.5 Features - JSON Serialization</title>
		<link>http://madhubaabu.blog.com/2008/03/25/net-35-features-json-serialization/</link>
		<comments>http://madhubaabu.blog.com/2008/03/25/net-35-features-json-serialization/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 10:46:50 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[.NET 3.5]]></category>

		<category><![CDATA[JSON Serialization]]></category>

		<category><![CDATA[Serialization]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[<p><b>Serialization &#38; Deserialization:</b><br />
The process of storing the state of an object to a storage medium. During this process, the public and private fields of the object and the name of the class, are converted to a stream of bytes, which is then written to a data stream. When the object is subsequently deserialized, an exact clone of the original object is created. Serialization/Deserialization is used to transport or to persist objects.<br />
<br />
<b>Types of Serialization :</b><br />
1. Binary Serialization<br />
2. SOAP Serialization<br />
3. XML Serialization<br />
4. Custom Serialization<br />
<br />
.NET 3.5 has new object called <b>DataContractJsonSerliaizer</b> used to JSON serialization&#160;for Ajax calls / Javascript calls.<br />
<br />
Here i am writing <b>JSONHelper</b> class to Serialize and Deserialize<br />
<i>Add Reference: System.Runtime.Serialization.dll(.NET 3.0), System.ServiceModel.Web.dll(.NET 3.5)</i></p>
<p><br />
using System.Collections.Generic;<br />
using System.Runtime.Serialization;<br />
using System.Runtime.Serialization.Json;<br />
public class JSONHelper<br />
{<br />
&#160;&#160;&#160; public static string Serialize(T obj)<br />
&#160;&#160;&#160; {<br />
&#160;&#160;&#160; DataContractJsonSerializer serializer = new DataContractJsonSerializer(obj.GetType());&#160;&#160;&#160;<br />
&#160;&#160;&#160; MemoryStream ms = new MemoryStream();<br />
&#160;&#160;&#160; serializer.WriteObject(ms, obj);<br />
&#160;&#160;&#160; string retVal = Encoding.Default.GetString(ms.ToArray());<br />
&#160;&#160;&#160; return retVal;<br />
&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160; public static T Deserialize(string json)<br />
&#160;&#160;&#160; {</p>
<p>&#160;&#160;&#160; T obj = Activator.CreateInstance();<br />
&#160;&#160;&#160; MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(json));</p>
<p>&#160;&#160;&#160; DataContractJsonSerializer serializer = new DataContractJsonSerializer(obj.GetType());<br />
&#160;&#160;&#160; obj = (T)serializer.ReadObject(ms);<br />
&#160;&#160;&#160; ms.Close();</p>
<p>&#160;&#160;&#160; return obj;<br />
&#160;&#160;&#160; }</p>
<p>}<br />
<b><i><br />
Below class going to use for&#160;serialization and Deserialization</i></b></p>
<p><b><i><br /></i></b>[DataContract]<br />
public class Book<br />
{</p>
<p>&#160;&#160;&#160; private int _id;&#160;&#160;&#160; private string _name;<br />
&#160;&#160;&#160; public Book() {}</p>
<p>&#160;&#160;&#160; public Book(int id, string name)<br />
&#160;&#160;&#160; {<br />
&#160;&#160;&#160; _id = id;<br />
&#160;&#160;&#160; _name = name;<br />
&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160;</p>
<p>&#160;&#160;&#160; [DataMember]&#160;&#160;&#160;<br />
&#160;&#160;&#160; public int Id<br />
&#160;&#160;&#160; {<br />
&#160;&#160;&#160; get { return _id; }</p>
<p>&#160;&#160;&#160; set { _id = value; }<br />
&#160;&#160;&#160; }</p>
<br />
<p>&#160;&#160;&#160; [DataMember]</p>
<p>&#160;&#160;&#160; public string Name<br />
&#160;&#160;&#160; {<br />
&#160;&#160;&#160; get { return _name; }</p>
<p>&#160;&#160;&#160; set { _name = value; }<br />
&#160;&#160;&#160; }<br />
}</p>
<p><br />
<b><i>How to Use JSONHelper class to Serialize</i></b></p>
<p>Book b1 = new Book(1, "ASP.NET 3.5");<br />
string jsonOutput = JSONHelper.Serialize&#60;Book&#62;(b1);<br />
<b><i><br /></i></b><b><i>Serialization output:</i></b><b><i><br /></i></b>{"Id":1,"Name":"ASP.NET 3.5"}<br />
<br />
<b><i>How to Use JSONHelper class to Deserialize</i></b><b><i><br /></i></b>Book b2 = JSONHelper.Deserialize&#60;Book&#62;(jsonOutput);</p>
<p><br />
<br />
<br />
<br />
&#160;</p>
<br />
]]></description>
			<content:encoded><![CDATA[<div>
<p><b>Serialization &amp; Deserialization:</b><br />
The process of storing the state of an object to a storage medium. During this process, the public and private fields of the object and the name of the class, are converted to a stream of bytes, which is then written to a data stream. When the object is subsequently deserialized, an exact clone of the original object is created. Serialization/Deserialization is used to transport or to persist objects.</p>
<p><b>Types of Serialization :</b><br />
1. Binary Serialization<br />
2. SOAP Serialization<br />
3. XML Serialization<br />
4. Custom Serialization</p>
<p>.NET 3.5 has new object called <b>DataContractJsonSerliaizer</b> used to JSON serialization&#160;for Ajax calls / Javascript calls.</p>
<p>Here i am writing <b>JSONHelper</b> class to Serialize and Deserialize<br />
<i>Add Reference: System.Runtime.Serialization.dll(.NET 3.0), System.ServiceModel.Web.dll(.NET 3.5)</i></p>
<p>
using System.Collections.Generic;<br />
using System.Runtime.Serialization;<br />
using System.Runtime.Serialization.Json;<br />
public class JSONHelper<br />
{<br />
&#160;&#160;&#160; public static string Serialize(T obj)<br />
&#160;&#160;&#160; {<br />
&#160;&#160;&#160; DataContractJsonSerializer serializer = new DataContractJsonSerializer(obj.GetType());&#160;&#160;&#160;<br />
&#160;&#160;&#160; MemoryStream ms = new MemoryStream();<br />
&#160;&#160;&#160; serializer.WriteObject(ms, obj);<br />
&#160;&#160;&#160; string retVal = Encoding.Default.GetString(ms.ToArray());<br />
&#160;&#160;&#160; return retVal;<br />
&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160; public static T Deserialize(string json)<br />
&#160;&#160;&#160; {</p>
<p>&#160;&#160;&#160; T obj = Activator.CreateInstance();<br />
&#160;&#160;&#160; MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(json));</p>
<p>&#160;&#160;&#160; DataContractJsonSerializer serializer = new DataContractJsonSerializer(obj.GetType());<br />
&#160;&#160;&#160; obj = (T)serializer.ReadObject(ms);<br />
&#160;&#160;&#160; ms.Close();</p>
<p>&#160;&#160;&#160; return obj;<br />
&#160;&#160;&#160; }</p>
<p>}<br />
<b><i><br />
Below class going to use for&#160;serialization and Deserialization</i></b></p>
<p><b><i><br /></i></b>[DataContract]<br />
public class Book<br />
{</p>
<p>&#160;&#160;&#160; private int _id;&#160;&#160;&#160; private string _name;<br />
&#160;&#160;&#160; public Book() {}</p>
<p>&#160;&#160;&#160; public Book(int id, string name)<br />
&#160;&#160;&#160; {<br />
&#160;&#160;&#160; _id = id;<br />
&#160;&#160;&#160; _name = name;<br />
&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160;</p>
<p>&#160;&#160;&#160; [DataMember]&#160;&#160;&#160;<br />
&#160;&#160;&#160; public int Id<br />
&#160;&#160;&#160; {<br />
&#160;&#160;&#160; get { return _id; }</p>
<p>&#160;&#160;&#160; set { _id = value; }<br />
&#160;&#160;&#160; }</p>
<p></p>
<p>&#160;&#160;&#160; [DataMember]</p>
<p>&#160;&#160;&#160; public string Name<br />
&#160;&#160;&#160; {<br />
&#160;&#160;&#160; get { return _name; }</p>
<p>&#160;&#160;&#160; set { _name = value; }<br />
&#160;&#160;&#160; }<br />
}</p>
<p>
<b><i>How to Use JSONHelper class to Serialize</i></b></p>
<p>Book b1 = new Book(1, &#8220;ASP.NET 3.5&#8243;);<br />
string jsonOutput = JSONHelper.Serialize&lt;Book&gt;(b1);<br />
<b><i><br /></i></b><b><i>Serialization output:</i></b><b><i><br /></i></b>{&#8221;Id&#8221;:1,&#8221;Name&#8221;:&#8221;ASP.NET 3.5&#8243;}</p>
<p><b><i>How to Use JSONHelper class to Deserialize</i></b><b><i><br /></i></b>Book b2 = JSONHelper.Deserialize&lt;Book&gt;(jsonOutput);</p>
<p>&#160;</p>
<p>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://madhubaabu.blog.com/2008/03/25/net-35-features-json-serialization/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Maintain your DDL commands log &#38; Restrict DDL commands in SQL Server 2005</title>
		<link>http://madhubaabu.blog.com/2008/01/09/maintain-your-ddl-commands-log-restrict-ddl-commands-in-sql-server-2005/</link>
		<comments>http://madhubaabu.blog.com/2008/01/09/maintain-your-ddl-commands-log-restrict-ddl-commands-in-sql-server-2005/#comments</comments>
		<pubDate>Thu, 10 Jan 2008 00:00:00 +0000</pubDate>
		<dc:creator></dc:creator>
		
		<category><![CDATA[SQL Server 2005]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[<br />
<strong><font size="4" color="#0000FF">Maintain your DDL commands log&#160;:</font><br /></strong><br />
<strong>1. Create Audit Schema( which ever schema name you like it)<br /></strong><font size="2" color="#0000FF">CREATE</font> <font size="2" color="#0000FF">SCHEMA</font> <font size="2">Audit<br /></font>
<p><font size="2">GO</font></p>
<font size="2" color="#0000FF"><font color="#000000"><strong>2. Create table to hold DDL command log data</strong></font><br />
CREATE <font size="2" color="#0000FF">TABLE</font> <font size="2">[Audit]</font><font size="2" color="#808080">.</font><font size="2">[DDLLog]</font><font size="2" color="#808080">(<br /></font><font size="2">[id] [int]</font> <font size="2" color="#0000FF">IDENTITY</font><font size="2" color="#808080">(</font><font size="2">1</font><font size="2" color="#808080">,</font><font size="2">1</font><font size="2" color="#808080">)</font> <font size="2" color="#808080">NOT</font> <font size="2" color="#808080">NULL,<br /></font><font size="2">[logData] [xml]</font> <font size="2" color="#808080">NOT</font> <font size="2" color="#808080">NULL,<br /></font><font size="2" color="#0000FF">CONSTRAINT</font> <font size="2">[PK_DDLLog]</font> <font size="2" color="#0000FF">PRIMARY</font> <font size="2" color="#0000FF">KEY</font> <font size="2" color="#0000FF">CLUSTERED<br /></font><font size="2" color="#808080">(</font><font size="2">[id]</font> <font size="2" color="#0000FF">ASC</font><font size="2" color="#808080">))</font> <font size="2" color="#0000FF">ON</font> <font size="2">[PRIMARY]<br />
GO<br />
<br />
<strong><font color="#000000">3. Create trigger to store DDL command in table when any DDL command executed in DB</font></strong><br /></font><font size="2" color="#0000FF">CREATE</font> <font size="2" color="#0000FF">TRIGGER</font> <font size="2">[Trig_DDLLog]<br /></font><font size="2" color="#0000FF">ON</font> <font size="2" color="#0000FF">DATABASE</font> <font size="2" color="#0000FF">FOR</font> <font size="2">DDL_DATABASE_LEVEL_EVENTS<br /></font> <font size="2" color="#0000FF">AS<br />
INSERT</font> <font size="2" color="#0000FF">INTO</font> <font size="2">[Audit]</font><font size="2" color="#808080">.</font><font size="2">[DDLLog]</font><font size="2" color="#808080">(</font><font size="2">logData</font><font size="2" color="#808080">)<br /></font><font size="2" color="#0000FF">SELECT</font> <font size="2">EVENTDATA</font><font size="2" color="#808080">()<br /></font><font size="2">GO<br />
<br />
<strong><font color="#000000">4. Enable Trigger</font></strong><br /></font><font size="2" color="#0000FF">ENABLE</font> <font size="2" color="#0000FF">TRIGGER</font> <font size="2">[Trig_DDLLog]</font> <font size="2" color="#0000FF">ON</font> <font size="2" color="#0000FF">DATABASE<br />
<br />
<br />
<font color="#000000">Thats all. Now on if you use any DDL command on DB, it maintains log in Audit.DDLLog table.<br />
____________________________________________________________<br />
<br />
<font size="4" color="#0000FF"><strong>Restrict DDL commands&#160;:<br />
<br /></strong><font size="2"><font color="#000000">Below Trigger restrict user from Droping tables and Altering tables.</font><font color="#000000">&#160;If you wanted to do that you must disable trigger first before you proceed to Alter or Drop table.<br /></font></font><br /></font></font></font></font>
<p><font size="2" color="#0000FF"><font size="2" color="#0000FF"><font color="#000000"><font size="4" color="#0000FF"><font size="2" color="#0000FF">CREATE <font size="2" color="#0000FF">TRIGGER</font> <font size="2"><font color="#000000">Trig_RestrictDropAlterTable<br /></font></font></font></font></font></font></font></p>
<p><font size="2" color="#0000FF"><font size="2" color="#0000FF"><font color="#000000"><font size="4" color="#0000FF"><font size="2" color="#0000FF">ON <font size="2" color="#0000FF">DATABASE<br /></font></font></font></font></font></font></p>
<p><font size="2" color="#0000FF"><font size="2" color="#0000FF"><font color="#000000"><font size="4" color="#0000FF"><font size="2" color="#0000FF">FOR <font size="2" color="#000000">DROP_TABLE</font><font size="2" color="#808080">,</font> <font size="2"><font color="#000000">ALTER_TABLE<br /></font></font></font></font></font></font></font></p>
<font size="2" color="#0000FF"><font size="2" color="#0000FF"><font color="#000000"><font size="4" color="#0000FF"><font size="2" color="#0000FF">AS<br /></font></font></font></font></font>
<p><font size="2" color="#0000FF"><font size="2" color="#0000FF"><font color="#000000"><font size="2"><font size="2" color="#0000FF">PRINT</font> <font size="2" color="#FF0000">'You must disable Trigger "Trig_RestrictDropAlterTable" to drop or alter tables!'<br /></font></font></font></font></font></p>
<font size="2" color="#0000FF"><font size="2" color="#0000FF"><font color="#000000"><font size="2" color="#0000FF">ROLLBACK<br /></font></font></font></font>
<p><font size="2" color="#0000FF"><font size="2" color="#0000FF"><font size="2" color="#0000FF"><br />
<font size="2"><strong><font color="#000000">To Disable Trigger<br /></font></strong>DISABLE&#160;<font color="#0000FF">TRIGGER</font> [<font color="#000000">Trig_RestrictDropAlterTable</font> ] <font color="#0000FF">ON</font> <font color="#0000FF">DATABASE</font></font><br />
<br />
<font size="2" color="#000000"><em>To provide next level of security from Droping and Altering tables, you can create schema, and give permissions to only one main user on newly created schema. Create this trigger under that schema. So others don't have permission to disable trigger.&#160;So others can't be able to modify DB structures. Only main users will disable trigger and do nessasary changes in structures.<br /></em></font><br /></font></font></font></p>
<div style="text-align: center"><font color="#000000">*** END ***</font></div>

]]></description>
			<content:encoded><![CDATA[<div>
<strong><font size="4" color="#0000FF">Maintain your DDL commands log&#160;:</font><br /></strong><br />
<strong>1. Create Audit Schema( which ever schema name you like it)<br /></strong><font size="2" color="#0000FF">CREATE</font> <font size="2" color="#0000FF">SCHEMA</font> <font size="2">Audit<br /></font></p>
<p><font size="2">GO</font></p>
<p><font size="2" color="#0000FF"><font color="#000000"><strong>2. Create table to hold DDL command log data</strong></font><br />
CREATE <font size="2" color="#0000FF">TABLE</font> <font size="2">[Audit]</font><font size="2" color="#808080">.</font><font size="2">[DDLLog]</font><font size="2" color="#808080">(<br /></font><font size="2">[id] [int]</font> <font size="2" color="#0000FF">IDENTITY</font><font size="2" color="#808080">(</font><font size="2">1</font><font size="2" color="#808080">,</font><font size="2">1</font><font size="2" color="#808080">)</font> <font size="2" color="#808080">NOT</font> <font size="2" color="#808080">NULL,<br /></font><font size="2">[logData] [xml]</font> <font size="2" color="#808080">NOT</font> <font size="2" color="#808080">NULL,<br /></font><font size="2" color="#0000FF">CONSTRAINT</font> <font size="2">[PK_DDLLog]</font> <font size="2" color="#0000FF">PRIMARY</font> <font size="2" color="#0000FF">KEY</font> <font size="2" color="#0000FF">CLUSTERED<br /></font><font size="2" color="#808080">(</font><font size="2">[id]</font> <font size="2" color="#0000FF">ASC</font><font size="2" color="#808080">))</font> <font size="2" color="#0000FF">ON</font> <font size="2">[PRIMARY]<br />
GO</p>
<p><strong><font color="#000000">3. Create trigger to store DDL command in table when any DDL command executed in DB</font></strong><br /></font><font size="2" color="#0000FF">CREATE</font> <font size="2" color="#0000FF">TRIGGER</font> <font size="2">[Trig_DDLLog]<br /></font><font size="2" color="#0000FF">ON</font> <font size="2" color="#0000FF">DATABASE</font> <font size="2" color="#0000FF">FOR</font> <font size="2">DDL_DATABASE_LEVEL_EVENTS<br /></font> <font size="2" color="#0000FF">AS<br />
INSERT</font> <font size="2" color="#0000FF">INTO</font> <font size="2">[Audit]</font><font size="2" color="#808080">.</font><font size="2">[DDLLog]</font><font size="2" color="#808080">(</font><font size="2">logData</font><font size="2" color="#808080">)<br /></font><font size="2" color="#0000FF">SELECT</font> <font size="2">EVENTDATA</font><font size="2" color="#808080">()<br /></font><font size="2">GO</p>
<p><strong><font color="#000000">4. Enable Trigger</font></strong><br /></font><font size="2" color="#0000FF">ENABLE</font> <font size="2" color="#0000FF">TRIGGER</font> <font size="2">[Trig_DDLLog]</font> <font size="2" color="#0000FF">ON</font> <font size="2" color="#0000FF">DATABASE</p>
<p>
<font color="#000000">Thats all. Now on if you use any DDL command on DB, it maintains log in Audit.DDLLog table.<br />
____________________________________________________________</p>
<p><font size="4" color="#0000FF"><strong>Restrict DDL commands&#160;:</p>
<p></strong><font size="2"><font color="#000000">Below Trigger restrict user from Droping tables and Altering tables.</font><font color="#000000">&#160;If you wanted to do that you must disable trigger first before you proceed to Alter or Drop table.<br /></font></font><br /></font></font></font></font></p>
<p><font size="2" color="#0000FF"><font size="2" color="#0000FF"><font color="#000000"><font size="4" color="#0000FF"><font size="2" color="#0000FF">CREATE <font size="2" color="#0000FF">TRIGGER</font> <font size="2"><font color="#000000">Trig_RestrictDropAlterTable<br /></font></font></font></font></font></font></font></p>
<p><font size="2" color="#0000FF"><font size="2" color="#0000FF"><font color="#000000"><font size="4" color="#0000FF"><font size="2" color="#0000FF">ON <font size="2" color="#0000FF">DATABASE<br /></font></font></font></font></font></font></p>
<p><font size="2" color="#0000FF"><font size="2" color="#0000FF"><font color="#000000"><font size="4" color="#0000FF"><font size="2" color="#0000FF">FOR <font size="2" color="#000000">DROP_TABLE</font><font size="2" color="#808080">,</font> <font size="2"><font color="#000000">ALTER_TABLE<br /></font></font></font></font></font></font></font></p>
<p><font size="2" color="#0000FF"><font size="2" color="#0000FF"><font color="#000000"><font size="4" color="#0000FF"><font size="2" color="#0000FF">AS<br /></font></font></font></font></font></p>
<p><font size="2" color="#0000FF"><font size="2" color="#0000FF"><font color="#000000"><font size="2"><font size="2" color="#0000FF">PRINT</font> <font size="2" color="#FF0000">&#8216;You must disable Trigger &#8220;Trig_RestrictDropAlterTable&#8221; to drop or alter tables!&#8217;<br /></font></font></font></font></font></p>
<p><font size="2" color="#0000FF"><font size="2" color="#0000FF"><font color="#000000"><font size="2" color="#0000FF">ROLLBACK<br /></font></font></font></font></p>
<p><font size="2" color="#0000FF"><font size="2" color="#0000FF"><font size="2" color="#0000FF"><br />
<font size="2"><strong><font color="#000000">To Disable Trigger<br /></font></strong>DISABLE&#160;<font color="#0000FF">TRIGGER</font> [<font color="#000000">Trig_RestrictDropAlterTable</font> ] <font color="#0000FF">ON</font> <font color="#0000FF">DATABASE</font></font></p>
<p><font size="2" color="#000000"><em>To provide next level of security from Droping and Altering tables, you can create schema, and give permissions to only one main user on newly created schema. Create this trigger under that schema. So others don&#8217;t have permission to disable trigger.&#160;So others can&#8217;t be able to modify DB structures. Only main users will disable trigger and do nessasary changes in structures.<br /></em></font><br /></font></font></font></p>
<div style="text-align: center"><font color="#000000">*** END ***</font></div>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://madhubaabu.blog.com/2008/01/09/maintain-your-ddl-commands-log-restrict-ddl-commands-in-sql-server-2005/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
