<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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/"
	>

<channel>
	<title>Dima's notes</title>
	<link>http://kostikov.co.uk/blog</link>
	<description>etc</description>
	<pubDate>Tue, 28 Jul 2009 10:35:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>Difference between ref and out in .net</title>
		<link>http://kostikov.co.uk/blog/?p=17</link>
		<comments>http://kostikov.co.uk/blog/?p=17#comments</comments>
		<pubDate>Tue, 28 Jul 2009 10:35:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[asp.net]]></category>

		<category><![CDATA[c#]]></category>

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

		<category><![CDATA[.net]]></category>

		<category><![CDATA[out parameters]]></category>

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

		<category><![CDATA[ref parameters]]></category>

		<guid isPermaLink="false">http://kostikov.co.uk/blog/?p=17</guid>
		<description><![CDATA[There are a couple of ways getting output parameters from .net procedures: you can use the keyword out or the keyword ref. Like so:
public void DoSmth&#40;ref int nRefVar&#41;&#123;&#125;
or
public void DoSmth&#40;out int nOutVar&#41;&#123;&#125;
What's the difference? Well, that's pretty easy. To pass a variable by reference, first you have create that reference by initializing the variable. Usually [...]]]></description>
			<content:encoded><![CDATA[<p>There are a couple of ways getting output parameters from .net procedures: you can use the keyword <strong>out </strong>or the keyword <strong>ref</strong>. Like so:</p>
<pre class="csharp"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> DoSmth<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ref</span> <span style="color: #FF0000;">int</span> nRefVar<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span></pre>
<p>or</p>
<pre class="csharp"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> DoSmth<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">out</span> <span style="color: #FF0000;">int</span> nOutVar<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span></pre>
<p>What's the difference? Well, that's pretty easy. To pass a variable by reference, first you have create that reference by initializing the variable. Usually you want to use this way when you're gonna use the value of the variable inside the function.</p>
<pre class="csharp"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> DoSmth<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ref</span> <span style="color: #FF0000;">int</span> nRefVar<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>nRef &amp;gt; <span style="color: #FF0000;">10</span><span style="color: #000000;">&#41;</span>
nRef = <span style="color: #FF0000;">5</span>;
<span style="color: #0600FF;">else</span>
nRef = <span style="color: #FF0000;">25</span>;
<span style="color: #000000;">&#125;</span>
<span style="color: #FF0000;">int</span> nRefVar = <span style="color: #FF0000;">10</span>;
DoSmth<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ref</span> nRefVar<span style="color: #000000;">&#41;</span>;</pre>
<p>To pass a variable as an <strong>out </strong>parameter you have only to declare it first. This way is just for getting the value. Usually you will need it when you have to get more than one return value from a procedure.</p>
<pre class="csharp"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> DoSmth<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">out</span> <span style="color: #FF0000;">int</span> nOutVar1, <span style="color: #0600FF;">out</span> <span style="color: #FF0000;">int</span> nOutVar2<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
nOutVar1 = <span style="color: #FF0000;">1</span>;
nOutVar2 = <span style="color: #FF0000;">2</span>;
<span style="color: #000000;">&#125;</span>
<span style="color: #FF0000;">int</span> nOutVar1, nOutVar2;
DoSmth<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">out</span> nOutVar1, <span style="color: #0600FF;">out</span> nOutVar2<span style="color: #000000;">&#41;</span>;</pre>
<p>Good Luck</p>
]]></content:encoded>
			<wfw:commentRss>http://kostikov.co.uk/blog/?feed=rss2&amp;p=17</wfw:commentRss>
		</item>
		<item>
		<title>asp.net interview question</title>
		<link>http://kostikov.co.uk/blog/?p=16</link>
		<comments>http://kostikov.co.uk/blog/?p=16#comments</comments>
		<pubDate>Fri, 24 Jul 2009 08:57:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[asp.net]]></category>

		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://kostikov.co.uk/blog/?p=16</guid>
		<description><![CDATA[Here is a list of some basic ASP.Net interview question. I've come across them here: http://weblogs.asp.net/anasghanem/archive/2008/02/22/common-net-technical-questions-that-you-will-be-asked-about-in-the-interviews.aspx
For those who looks for a new job  
1. Explain the life cycle of an ASP .NET page.
2. Explain the .NET architecture.
3. What are object-oriented concepts?
4. How do you create multiple inheritance in c# and .NET?
5. When is web.config called?
6. Differences between DLL and EXE?
7. Can [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a list of some basic ASP.Net interview question. I've come across them here: http://weblogs.asp.net/anasghanem/archive/2008/02/22/common-net-technical-questions-that-you-will-be-asked-about-in-the-interviews.aspx</p>
<p>For those who looks for a new job <img src='http://kostikov.co.uk/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span style="display: block" class="ACECollapsed" border="0" id="divExpCollAsst_39"><font face="Arial">1. Explain the life cycle of an ASP .NET page.<br />
2. Explain the .NET architecture.<br />
3. What are object-oriented concepts?<br />
4. How do you create multiple inheritance in c# and .NET?<br />
5. When is web.config called?<br />
6. Differences between DLL and EXE?<br />
7. Can an assembly have EXE?<br />
8. Can a DLL be changed to an EXE?<br />
9. Compare &amp; contrast rich client (smart clients or Windows-based) &amp; browser-based Web application<br />
10. Compare Client server application with n-Tier application<br />
11. Can a try block have more than one catch block?<br />
12. Can a try block have nested try blocks?<br />
13. How do you load an assembly at runtime?<br />
14. If I am writing in a language like VB or C++, what are the procedures to be followed to support .NET?<br />
15. How do you view the methods and members of a DLL?<br />
16. What is shadowing?<br />
17. What are the collections you’ve used?<br />
18. What is a static class?<br />
19. What is static member?<br />
20. What is static function?<br />
21. What is static constructor?<br />
22. How can we inherit a static variable?<br />
23. How can we inherit a static member?<br />
24. Can we use a static function with a non-static variable?<br />
25. How can we access static variable?<br />
26. Why main function is static?<br />
27. What is garbage collection?<br />
28. Can we force garbage collector to run?<br />
29. What is reflection?<br />
30. What are different type of JIT?<br />
31. What are Value types and Reference types?<br />
32. What is concept of Boxing and Unboxing?<br />
33. What’s difference between VB.NET and C#?<br />
34. What’s difference between System exceptions and Application exceptions?<br />
35. What is CODE Access security?<br />
36. What is a satellite assembly?<br />
37. How to prevent my .NET DLL to be decompiled?<br />
38. What’s the difference between Convert.toString and .toString() method ?<br />
39. What is Native Image Generator (Ngen.exe)?<br />
We have two version of the same assembly in GAC? I want my client to make choice which assembly to choose?<br />
40. What is CodeDom?</font></span></p>
]]></content:encoded>
			<wfw:commentRss>http://kostikov.co.uk/blog/?feed=rss2&amp;p=16</wfw:commentRss>
		</item>
		<item>
		<title>Uploading and executing an SQL Script File using ASP.Net and osql</title>
		<link>http://kostikov.co.uk/blog/?p=15</link>
		<comments>http://kostikov.co.uk/blog/?p=15#comments</comments>
		<pubDate>Fri, 11 Apr 2008 09:53:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[asp.net]]></category>

		<category><![CDATA[c#]]></category>

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

		<category><![CDATA[executing file]]></category>

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

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

		<guid isPermaLink="false">http://kostikov.co.uk/blog/?p=15</guid>
		<description><![CDATA[Now I am gonna tell how to upload a file containg T-SQL script using ASP.Net and execute entire of the file using osql utility tool.
Note: This example is using the UploadFile method from the previous article
&#160;
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.IO;
using System.Diagnostics;    
&#160;
// some code goes here
// ..................
// ...................   [...]]]></description>
			<content:encoded><![CDATA[<p>Now I am gonna tell how to upload a file containg T-SQL script using ASP.Net and execute entire of the file using osql utility tool.<br />
Note: This example is using the UploadFile method from the <a href="http://kostikov.co.uk/blog/?p=14">previous article</a></p>
<pre class="csharp">&nbsp;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span>.<span style="color: #0000FF;">HtmlControls</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span>.<span style="color: #0000FF;">WebControls</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">IO</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Diagnostics</span>;    
&nbsp;
<span style="color: #008080; font-style: italic;">// some code goes here</span>
<span style="color: #008080; font-style: italic;">// ..................</span>
<span style="color: #008080; font-style: italic;">// ...................    </span>
&nbsp;
<span style="color: #FF0000;">string</span> strResult = <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Empty</span>;
<span style="color: #008080; font-style: italic;">// first of all the file should be uploaded</span>
<span style="color: #008080; font-style: italic;">// let's use the UploadFile procedure from the previous article</span>
<span style="color: #FF0000;">string</span> strFileName = <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Empty</span>;
<span style="color: #FF0000;">string</span> strBaseFolder = <span style="color: #808080;">&quot;c:<span style="color: #008080; font-weight: bold;">\u</span>ploads&quot;</span>;
<span style="color: #FF0000;">string</span> strFolder = Path.<span style="color: #0000FF;">Combine</span><span style="color: #000000;">&#40;</span>strBaseFolder, Guid.<span style="color: #0000FF;">NewGuid</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #FF0000;">bool</span> bIsOk;
<span style="color: #0600FF;">try</span>
<span style="color: #000000;">&#123;</span>
	bIsOk = UploadFile<span style="color: #000000;">&#40;</span>FileInputControl, strFolder, <span style="color: #0600FF;">ref</span> strFileName<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
<span style="color: #0600FF;">catch</span>
<span style="color: #000000;">&#123;</span>
	bIsOk = <span style="color: #0600FF;">false</span>;
<span style="color: #000000;">&#125;</span>    
&nbsp;
<span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>bIsOk<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #008080; font-style: italic;">// getting full file path</span>
	<span style="color: #FF0000;">string</span> strFilePath = Path.<span style="color: #0000FF;">Combine</span><span style="color: #000000;">&#40;</span>strFolder, strFileName<span style="color: #000000;">&#41;</span>;    
&nbsp;
	<span style="color: #008080; font-style: italic;">// here we should set connection parameters (i.e. they could be taken from web.config)</span>
	<span style="color: #FF0000;">string</span> strServerName = <span style="color: #808080;">&quot;&quot;</span>, strDBName = <span style="color: #808080;">&quot;&quot;</span>, strUserName = <span style="color: #808080;">&quot;&quot;</span>, strPassword = <span style="color: #808080;">&quot;&quot;</span>;    
&nbsp;
	<span style="color: #008080; font-style: italic;">// executing entire script</span>
	<span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>Process proc = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Process<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		proc.<span style="color: #0000FF;">StartInfo</span>.<span style="color: #0000FF;">FileName</span> = <span style="color: #808080;">&quot;osql&quot;</span>;
		proc.<span style="color: #0000FF;">StartInfo</span>.<span style="color: #0000FF;">Arguments</span> = <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;/S {0} /U {1} /P {2} /d {3} /i {4}&quot;</span>,
			strServerName, strUserName, strPassword, strDBName, strFilePath<span style="color: #000000;">&#41;</span>;
		proc.<span style="color: #0000FF;">StartInfo</span>.<span style="color: #0000FF;">UseShellExecute</span> = <span style="color: #0600FF;">false</span>;
		proc.<span style="color: #0000FF;">StartInfo</span>.<span style="color: #0000FF;">RedirectStandardOutput</span> = <span style="color: #0600FF;">true</span>;
		proc.<span style="color: #0000FF;">StartInfo</span>.<span style="color: #0000FF;">RedirectStandardError</span> = <span style="color: #0600FF;">true</span>;
		proc.<span style="color: #0000FF;">StartInfo</span>.<span style="color: #0000FF;">CreateNoWindow</span> = <span style="color: #0600FF;">true</span>;
		<span style="color: #0600FF;">try</span>
		<span style="color: #000000;">&#123;</span>
			proc.<span style="color: #0000FF;">Start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			proc.<span style="color: #0000FF;">WaitForExit</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			strResult = proc.<span style="color: #0000FF;">StandardOutput</span>.<span style="color: #0000FF;">ReadToEnd</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			proc.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0600FF;">catch</span>
		<span style="color: #000000;">&#123;</span>
			strResult = <span style="color: #808080;">@"The script can not be executed.
                                           Make sure there is osql utility on the server.&quot;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>    
&nbsp;
	<span style="color: #008080; font-style: italic;">// now lets delete the file as we don't want it to be saved on the server</span>
	Directory.<span style="color: #0000FF;">Delete</span><span style="color: #000000;">&#40;</span>strFolder, <span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
<span style="color: #0600FF;">else</span>
<span style="color: #000000;">&#123;</span>
	strResult = <span style="color: #808080;">&quot;The file cannot be uploaded to the server&quot;</span>;
<span style="color: #000000;">&#125;</span>    
&nbsp;
<span style="color: #008080; font-style: italic;">// now we could display strResult variable containg information about script execution</span>
<span style="color: #008080; font-style: italic;">// i.e. using Response.Write method</span>
Page.<span style="color: #0000FF;">Response</span>.<span style="color: #0000FF;">Write</span><span style="color: #000000;">&#40;</span>strResult<span style="color: #000000;">&#41;</span>;</pre>
<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://kostikov.co.uk/blog/?feed=rss2&amp;p=15</wfw:commentRss>
		</item>
		<item>
		<title>Uploading a file using ASP.Net</title>
		<link>http://kostikov.co.uk/blog/?p=14</link>
		<comments>http://kostikov.co.uk/blog/?p=14#comments</comments>
		<pubDate>Thu, 10 Apr 2008 13:20:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[asp.net]]></category>

		<category><![CDATA[c#]]></category>

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

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

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

		<guid isPermaLink="false">http://kostikov.co.uk/blog/?p=14</guid>
		<description><![CDATA[I know there are loads of articles related to uploading a file usin ASP.Net application. But still there is my method of doing that. Usually while creating a web application all my pages extend one base class but not the Page class. I always create some base class which extends the Page, so I could [...]]]></description>
			<content:encoded><![CDATA[<p>I know there are loads of articles related to uploading a file usin ASP.Net application. But still there is my method of doing that. Usually while creating a web application all my pages extend one base class but not the Page class. I always create some base class which extends the Page, so I could add some basic functionality and it and use it on any page I want. So the UploadFile procedure would on the methods of my base page class.</p>
<pre class="csharp">&nbsp;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span>.<span style="color: #0000FF;">WebControls</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span>.<span style="color: #0000FF;">HtmlControls</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">IO</span>;    
&nbsp;
<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> MyPage : Page
<span style="color: #000000;">&#123;</span>
..........
    <span style="color: #008080; font-style: italic;">// strUploadFolder - full path to the folder in which we are gonna store the file (i.e c:\savehere)</span>
    <span style="color: #008080; font-style: italic;">// strFileName - return parameter, that will store upaded file's name</span>
    <span style="color: #008080; font-style: italic;">// function returns true if uploading has been successfull, otherwise we get false</span>
    <span style="color: #0600FF;">protected</span> <span style="color: #FF0000;">bool</span> UploadFile<span style="color: #000000;">&#40;</span>HtmlInputFile fileinput, <span style="color: #FF0000;">string</span> strUploadFolder, <span style="color: #0600FF;">ref</span> <span style="color: #FF0000;">string</span> strFileName<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        HttpPostedFile myFile = fileinput.<span style="color: #0000FF;">PostedFile</span>;
        <span style="color: #FF0000;">int</span> nFileLen = myFile.<span style="color: #0000FF;">ContentLength</span>;
        strFileName = <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Empty</span>;
        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>nFileLen &amp;gt; <span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #FF0000;">byte</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> myData = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #FF0000;">byte</span><span style="color: #000000;">&#91;</span>nFileLen<span style="color: #000000;">&#93;</span>;
            myFile.<span style="color: #0000FF;">InputStream</span>.<span style="color: #0000FF;">Read</span><span style="color: #000000;">&#40;</span>myData, <span style="color: #FF0000;">0</span>, nFileLen<span style="color: #000000;">&#41;</span>;
            strFileName = Path.<span style="color: #0000FF;">GetFileName</span><span style="color: #000000;">&#40;</span>myFile.<span style="color: #0000FF;">FileName</span><span style="color: #000000;">&#41;</span>;    
&nbsp;
            <span style="color: #0600FF;">try</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>!Directory.<span style="color: #0000FF;">Exists</span><span style="color: #000000;">&#40;</span>strUploadFolder<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
	       Directory.<span style="color: #0000FF;">CreateDirectory</span><span style="color: #000000;">&#40;</span>strUploadFolder<span style="color: #000000;">&#41;</span>;
                <span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>FileStream newFile = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> FileStream<span style="color: #000000;">&#40;</span>Path.<span style="color: #0000FF;">Combine</span><span style="color: #000000;">&#40;</span>strUploadFolder, strFileName<span style="color: #000000;">&#41;</span>,
                                       FileMode.<span style="color: #0000FF;">Create</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
	   <span style="color: #000000;">&#123;</span>
	       newFile.<span style="color: #0000FF;">Write</span><span style="color: #000000;">&#40;</span>myData, <span style="color: #FF0000;">0</span>, myData.<span style="color: #0000FF;">Length</span><span style="color: #000000;">&#41;</span>;
	       newFile.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
                <span style="color: #000000;">&#125;</span>
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0600FF;">catch</span> <span style="color: #000000;">&#40;</span>Exception ex<span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0600FF;">throw</span> ex;
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">true</span>;
        <span style="color: #000000;">&#125;</span>
        <span style="color: #0600FF;">else</span>
            <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">false</span>;
    <span style="color: #000000;">&#125;</span>
..........
<span style="color: #000000;">&#125;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://kostikov.co.uk/blog/?feed=rss2&amp;p=14</wfw:commentRss>
		</item>
		<item>
		<title>Adding a new column to a MS SQL Table safely</title>
		<link>http://kostikov.co.uk/blog/?p=13</link>
		<comments>http://kostikov.co.uk/blog/?p=13#comments</comments>
		<pubDate>Tue, 08 Apr 2008 10:59:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[sql]]></category>

		<category><![CDATA[add a column]]></category>

		<category><![CDATA[alter table]]></category>

		<category><![CDATA[t-sql]]></category>

		<guid isPermaLink="false">http://kostikov.co.uk/blog/?p=13</guid>
		<description><![CDATA[How could we check if a column exists and add it to a table if it doesn't? Very easily!
&#160;
IF NOT EXISTS
	&#40;SELECT * FROM syscolumns
	WHERE id = OBJECT_ID&#40;N'[MyTable]'&#41; AND name = 'MyColumn'&#41;
             ALTER TABLE dbo.MyTable ADD MyColumn INT
Enjoy!
]]></description>
			<content:encoded><![CDATA[<p>How could we check if a column exists and add it to a table if it doesn't? Very easily!</p>
<pre class="tsql">&nbsp;
<span style="color: #0000FF;">IF</span> NOT EXISTS
	<span style="color: #808080;">&#40;</span><span style="color: #0000FF;">SELECT</span> * <span style="color: #0000FF;">FROM</span> syscolumns
	<span style="color: #0000FF;">WHERE</span> id = <span style="color: #FF00FF;">OBJECT_ID</span><span style="color: #808080;">&#40;</span>N<span style="color: #FF0000;">'[MyTable]'</span><span style="color: #808080;">&#41;</span> AND name = <span style="color: #FF0000;">'MyColumn'</span><span style="color: #808080;">&#41;</span>
             <span style="color: #0000FF;">ALTER</span> <span style="color: #0000FF;">TABLE</span> dbo.<span style="color: #202020;">MyTable</span> <span style="color: #0000FF;">ADD</span> MyColumn <span style="color: #0000FF;">INT</span></pre>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://kostikov.co.uk/blog/?feed=rss2&amp;p=13</wfw:commentRss>
		</item>
		<item>
		<title>ASP.Net QueryString Builder</title>
		<link>http://kostikov.co.uk/blog/?p=11</link>
		<comments>http://kostikov.co.uk/blog/?p=11#comments</comments>
		<pubDate>Tue, 25 Mar 2008 12:25:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[asp.net]]></category>

		<category><![CDATA[c#]]></category>

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

		<guid isPermaLink="false">http://kostikov.co.uk/blog/?p=11</guid>
		<description><![CDATA[I was trying to find any classes allowing easily modify querystring. I have found a couple of good ones but not ideal for me. So I have created my own class. It has a number of static functions which could be called without creating an instance of the class - if you need to use [...]]]></description>
			<content:encoded><![CDATA[<p>I was trying to find any classes allowing easily modify querystring. I have found a couple of good ones but not ideal for me. So I have created my own class. It has a number of static functions which could be called without creating an instance of the class - if you need to use some basic stuff. Here it is:</p>
<pre class="csharp">&nbsp;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Collections</span>.<span style="color: #0000FF;">Generic</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Linq</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Text</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span>.<span style="color: #0000FF;">HtmlControls</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span>.<span style="color: #0000FF;">WebControls</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Collections</span>;
<span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Collections</span>.<span style="color: #0000FF;">Specialized</span>;
&nbsp;
<span style="color: #0600FF;">namespace</span> ClassLibrary
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> QueryStringBuilder
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">protected</span> NameValueCollection m_QueryString;
&nbsp;
        <span style="color: #0600FF;">public</span> QueryStringBuilder<span style="color: #000000;">&#40;</span>NameValueCollection nvcQueryString<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            m_QueryString = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> NameValueCollection<span style="color: #000000;">&#40;</span>nvcQueryString<span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// static function returning a new querystring with a new parameter</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> NameValueCollection QSWithParameter<span style="color: #000000;">&#40;</span>NameValueCollection nvcCurrentQS,
                                                      <span style="color: #FF0000;">string</span> strParameterName, <span style="color: #FF0000;">string</span> strParameterValue<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            NameValueCollection nvcQS = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> NameValueCollection<span style="color: #000000;">&#40;</span>nvcCurrentQS<span style="color: #000000;">&#41;</span>;
&nbsp;
            <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> i = <span style="color: #FF0000;">0</span>; i &amp;lt; nvcQS.<span style="color: #0000FF;">Count</span>; i++<span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>nvcQS.<span style="color: #0000FF;">GetKey</span><span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span> == <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    nvcQS.<span style="color: #0000FF;">Remove</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>;
                    <span style="color: #0600FF;">break</span>;
                <span style="color: #000000;">&#125;</span>
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>nvcQS.<span style="color: #0000FF;">GetValues</span><span style="color: #000000;">&#40;</span>strParameterName<span style="color: #000000;">&#41;</span> == <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
                nvcQS.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>strParameterName, strParameterValue<span style="color: #000000;">&#41;</span>;
            <span style="color: #0600FF;">else</span>
                nvcQS<span style="color: #000000;">&#91;</span>strParameterName<span style="color: #000000;">&#93;</span> = strParameterValue;
            <span style="color: #0600FF;">return</span> nvcQS;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// function returning a new querystring with a new parameter</span>
        <span style="color: #0600FF;">public</span> NameValueCollection QSWithParameter<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> strParameterName, <span style="color: #FF0000;">string</span> strParameterValue<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> QSWithParameter<span style="color: #000000;">&#40;</span>m_QueryString, strParameterName, strParameterValue<span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// static function returning a querystring without a parameter</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> NameValueCollection QSWithoutParameter<span style="color: #000000;">&#40;</span>NameValueCollection nvcCurrentQS,
                                                                               <span style="color: #FF0000;">string</span> strParameterName<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            NameValueCollection nvcQS = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> NameValueCollection<span style="color: #000000;">&#40;</span>nvcCurrentQS<span style="color: #000000;">&#41;</span>;
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>nvcQS.<span style="color: #0000FF;">GetValues</span><span style="color: #000000;">&#40;</span>strParameterName<span style="color: #000000;">&#41;</span> != <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
                nvcQS.<span style="color: #0000FF;">Remove</span><span style="color: #000000;">&#40;</span>strParameterName<span style="color: #000000;">&#41;</span>;
            <span style="color: #0600FF;">return</span> nvcQS;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// function returning a querystring without a parameter</span>
        <span style="color: #0600FF;">public</span> NameValueCollection QSWithoutParameter<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> strParameterName<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> QSWithoutParameter<span style="color: #000000;">&#40;</span>m_QueryString, strParameterName<span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// static function returning url with a querystring</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">string</span> UrlWithQueryString<span style="color: #000000;">&#40;</span>NameValueCollection nvcQueryString, <span style="color: #FF0000;">string</span> strUrl<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #FF0000;">int</span> nQS = strUrl.<span style="color: #0000FF;">IndexOf</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;?&quot;</span><span style="color: #000000;">&#41;</span>;
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>nQS &amp;gt; <span style="color: #FF0000;">-1</span><span style="color: #000000;">&#41;</span>
                strUrl = strUrl.<span style="color: #0000FF;">Substring</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span>, nQS<span style="color: #000000;">&#41;</span>;
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>nvcQueryString.<span style="color: #0000FF;">Count</span> &amp;gt; <span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> i = <span style="color: #FF0000;">0</span>; i &amp;lt; nvcQueryString.<span style="color: #0000FF;">Count</span>; i++<span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    strUrl += <span style="color: #FF0000;">String</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;{0}{1}={2}&quot;</span>, i == <span style="color: #FF0000;">0</span> ? <span style="color: #808080;">&quot;?&quot;</span> : <span style="color: #808080;">&quot;&amp;amp;&quot;</span>, nvcQueryString.<span style="color: #0000FF;">Keys</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>,
                                                                                    nvcQueryString<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;
                <span style="color: #000000;">&#125;</span>
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0600FF;">return</span> strUrl;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// static function returning RawUrl with a querystring</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">string</span> UrlWithQueryString<span style="color: #000000;">&#40;</span>NameValueCollection nvcQueryString<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> UrlWithQueryString<span style="color: #000000;">&#40;</span>nvcQueryString, HttpContext.<span style="color: #0000FF;">Current</span>.<span style="color: #0000FF;">Request</span>.<span style="color: #0000FF;">RawUrl</span><span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// function returning url with a current querystring</span>
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> UrlWithQueryString<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> strUrl<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> UrlWithQueryString<span style="color: #000000;">&#40;</span>m_QueryString, strUrl<span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// function returning RawUrl with a current querystring</span>
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> UrlWithQueryString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> UrlWithQueryString<span style="color: #000000;">&#40;</span>m_QueryString<span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// procedure removing a parameter from a current querystring</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> RemoveQSParameter<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> strParameterName<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            m_QueryString = QSWithoutParameter<span style="color: #000000;">&#40;</span>strParameterName<span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// procedure adding a parameter to a current querystring</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> SetQSParameter<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> strParameterName, <span style="color: #FF0000;">string</span> strParameterValue<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            m_QueryString = QSWithParameter<span style="color: #000000;">&#40;</span>strParameterName, strParameterValue<span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://kostikov.co.uk/blog/?feed=rss2&amp;p=11</wfw:commentRss>
		</item>
		<item>
		<title>ASP.Net 3.5. Where?</title>
		<link>http://kostikov.co.uk/blog/?p=10</link>
		<comments>http://kostikov.co.uk/blog/?p=10#comments</comments>
		<pubDate>Sat, 22 Mar 2008 22:52:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[asp.net]]></category>

		<category><![CDATA[asp.net. .net]]></category>

		<guid isPermaLink="false">http://kostikov.co.uk/blog/?p=10</guid>
		<description><![CDATA[Just found a funny article explaining why after installing .Net 3.5 we can't select ASP.Net 3.5 under a ASP.Net version tab in IIS while setting up a site. I thought the answer was obvious - nobody had said about changing a version of ASP.Net - it is still 2 
]]></description>
			<content:encoded><![CDATA[<p>Just found a <a href="http://blogs.msdn.com/vijaysk/archive/2008/03/20/running-asp-net-3-5-on-iis.aspx" target="_blank">funny article</a> explaining why after installing .Net 3.5 we can't select ASP.Net 3.5 under a ASP.Net version tab in IIS while setting up a site. I thought the answer was obvious - nobody had said about changing a version of ASP.Net - it is still 2 <img src='http://kostikov.co.uk/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://kostikov.co.uk/blog/?feed=rss2&amp;p=10</wfw:commentRss>
		</item>
		<item>
		<title>Coding web forms html</title>
		<link>http://kostikov.co.uk/blog/?p=9</link>
		<comments>http://kostikov.co.uk/blog/?p=9#comments</comments>
		<pubDate>Fri, 21 Mar 2008 18:24:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[asp.net]]></category>

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

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

		<category><![CDATA[semantic form]]></category>

		<guid isPermaLink="false">http://kostikov.co.uk/blog/?p=9</guid>
		<description><![CDATA[Coding client html of web-forms is not the easiest and not the most interesting part of developing a web-application. There are loads of ways of doing that. But the question is - which one is the right one? The html code should be semantyc, accessible and obvious for other developers. So I tried googling and [...]]]></description>
			<content:encoded><![CDATA[<p>Coding client html of web-forms is not the easiest and not the most interesting part of developing a web-application. There are loads of ways of doing that. But the question is - which one is the right one? The html code should be semantyc, accessible and obvious for other developers. So I tried googling and found <a href="http://www.themaninblue.com/writing/perspective/2004/03/24/" target="blank_">this article</a> that seemed very interesting to me. How that could've been more obvious that fieldsets and labels should be used for developing web-forms? And by using CSS we could make the form look in many different ways!</p>
<p>Have a look at the following example:</p>
<pre class="html4strict">&nbsp;
<span style="color: #009900;"><a href="http://december.com/html/4/element/fieldset.html"><span style="color: #000000; font-weight: bold;">&lt;fieldset</span></a> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;form-fieldset&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">&lt;label</span></a> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;textbox surname&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><a href="http://december.com/html/4/element/span.html"><span style="color: #000000; font-weight: bold;">&lt;span&gt;</span></a></span>Surname<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">&lt;input</span></a> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;surname&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;surname&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/label&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fieldset&gt;</span></span></pre>
<p>Now with a help of CSS we could access any element of this form. Very flexible. We could use as many fieldsets as we could wish. We could even have fieldsets inside fieldsets.</p>
<p>Alright. Later I started thinking how I could use that for simplify the way of creating asp.net web forms. So I created a class FieldSet</p>
<pre class="csharp">&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> FieldSet : HtmlGenericControl
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">public</span> FieldSet<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
            : <span style="color: #0600FF;">base</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;fieldset&quot;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span> <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> FieldSet<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> strLegend<span style="color: #000000;">&#41;</span>
            : <span style="color: #0600FF;">this</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            HtmlGenericControl legend = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> HtmlGenericControl<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;legend&quot;</span><span style="color: #000000;">&#41;</span>;
            Controls.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>legend<span style="color: #000000;">&#41;</span>;
            legend.<span style="color: #0000FF;">InnerText</span> = strLegend;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// as an example I have created this simple method which allows add a new input text to the fieldset</span>
        <span style="color: #0600FF;">public</span> HtmlInputText AddInputText<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> strLabel, <span style="color: #FF0000;">string</span> strCSSClass<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            HtmlInputText txt = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> HtmlInputText<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
            AddControl<span style="color: #000000;">&#40;</span>strLabel, txt, strCSSClass<span style="color: #000000;">&#41;</span>;
            <span style="color: #0600FF;">return</span> txt;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> HtmlInputText AddInputText<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> strLabel<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> AddInputText<span style="color: #000000;">&#40;</span>strLabel, <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// this method is used for adding any web contol to the fieldset</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> AddControl<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> strLabel, Control cntrl, <span style="color: #FF0000;">string</span> strCSSClass<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            HtmlGenericControl label = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> HtmlGenericControl<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;label&quot;</span><span style="color: #000000;">&#41;</span>;
            Controls.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>label<span style="color: #000000;">&#41;</span>;
            label.<span style="color: #0000FF;">Controls</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> LiteralControl<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;&lt;span&gt;&quot;</span> + strLabel + <span style="color: #808080;">&quot;&lt;/span&gt;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>strCSSClass != <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
                label.<span style="color: #0000FF;">Attributes</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">&quot;class&quot;</span><span style="color: #000000;">&#93;</span> = strCSSClass;
&nbsp;
            label.<span style="color: #0000FF;">Controls</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>cntrl<span style="color: #000000;">&#41;</span>;
            cntrl.<span style="color: #0000FF;">ID</span> = ID + <span style="color: #808080;">&quot;_cntrl_&quot;</span> + Controls.<span style="color: #0000FF;">Count</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
            label.<span style="color: #0000FF;">Attributes</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">&quot;for&quot;</span><span style="color: #000000;">&#93;</span> = cntrl.<span style="color: #0000FF;">ClientID</span>;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> AddControl<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> strLabel, Control cntrl<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            AddControl<span style="color: #000000;">&#40;</span>strLabel, cntrl, <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span></pre>
<p>So now while developing another asp.net web-form I just could write the code:</p>
<pre class="csharp">&nbsp;
.....
<span style="color: #0000FF;">FieldSet</span> fs = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> FieldSet<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Editing surname&quot;</span><span style="color: #000000;">&#41;</span>;
Controls.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>fs<span style="color: #000000;">&#41;</span>;
HtmlInputText txtSurname = fs.<span style="color: #0000FF;">AddInputText</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Surname:&quot;</span>, <span style="color: #808080;">&quot;surname&quot;</span><span style="color: #000000;">&#41;</span>;
.....</pre>
<p>See? Just three lines of code.</p>
]]></content:encoded>
			<wfw:commentRss>http://kostikov.co.uk/blog/?feed=rss2&amp;p=9</wfw:commentRss>
		</item>
		<item>
		<title>Generating Business Objects</title>
		<link>http://kostikov.co.uk/blog/?p=7</link>
		<comments>http://kostikov.co.uk/blog/?p=7#comments</comments>
		<pubDate>Tue, 18 Mar 2008 10:22:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[c#]]></category>

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

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

		<guid isPermaLink="false">http://kostikov.co.uk/blog/?p=7</guid>
		<description><![CDATA[Once I was developing an application which was accessing a database. So the database had a number of tables (more than 10) for which I had to create business objects.  Almost each table TableName had to have a class CTableName containing every field of the table. And also for every class I had  [...]]]></description>
			<content:encoded><![CDATA[<p>Once I was developing an application which was accessing a database. So the database had a number of tables (more than 10) for which I had to create business objects.  Almost each table TableName had to have a class CTableName containing every field of the table. And also for every class I had  to create a collection class CTableNameCollection. I didn't feel like doing that manually so I created an SQL script.</p>
<p>The script has its parameters:</p>
<p><font color="#0000ff">SET </font>@BOPrefix = <font color="#ff0000">'C'                                                           <font color="#808000">- - Prefix of the business object</font></font><br />
<font color="#0000ff">SET </font>@TablePrefix =<font color="#ff0000"> 'dt_'                                                    <font color="#808000">- - Table prefix if it has any</font></font><br />
<font color="#0000ff">SET </font>@TableName = <font color="#ff0000">'dt_Customer'                                      <font color="#808000">--  Table for wich we need to generate the business object</font></font><br />
<font color="#0000ff">SET </font>@CurrentNamespace = <font color="#ff0000">'BusinessObjects'             <font color="#808000">- - A namespace in which we are gonna create the business object</font></font><br />
<font color="#0000ff">SET </font>@ReplacePKWithID = 1                                        <font color="#808000">- - In case we have a primary key field named CustomerID but in the business oject we wanna replace it with 'ID'</font><br />
<font color="#0000ff">SET </font>@IDPropertyName =<font color="#ff0000"> 'ID'</font>                                               <font color="#808000">  - - The name of the field we are gonna use to rename ID column in the business object</font></p>
<p>I have attached the script to this post.</p>
<p>files: <a href="http://kostikov.co.uk/blog/wp-content/uploads/2008/03/generatebusinessobjects.sql" title="Generating Business Objects">Generating Business Objects</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kostikov.co.uk/blog/?feed=rss2&amp;p=7</wfw:commentRss>
		</item>
		<item>
		<title>Developing Data Layer: Creating Stored Procedures (MS SQL 2000)</title>
		<link>http://kostikov.co.uk/blog/?p=5</link>
		<comments>http://kostikov.co.uk/blog/?p=5#comments</comments>
		<pubDate>Fri, 14 Mar 2008 22:38:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[development]]></category>

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

		<category><![CDATA[ms sql server 2000]]></category>

		<guid isPermaLink="false">http://kostikov.co.uk/blog/?p=5</guid>
		<description><![CDATA[Starting creating an application that is going to access a database the first thing I do is I am creating stored procedures. The sprocs have to be as simple as possible as I am not gonna implement any business logic within them. So all they should do is to insert, update, retrieve and delete information. [...]]]></description>
			<content:encoded><![CDATA[<p>Starting creating an application that is going to access a database the first thing I do is I am creating stored procedures. The sprocs have to be as simple as possible as I am not gonna implement any business logic within them. So all they should do is to insert, update, retrieve and delete information. To simplify the process of the creating that sprocs I have created a simple sql script wich creates them automatically. All I have to do now is to set the parameters of the script, press F5 in my Query Analyzer or SQL Management Studio, copy results of the execution from the message window, paste them into a new window, then probably modify the pasted script (if I need to change any specific settings) and finally press F5 again to create the sprocs.</p>
<p>The parameters I need to modify are:</p>
<p><font color="#0000ff">SET </font>@ProcedurePrefix = <font color="#ff0000">'usp_'  <font color="#808000">-- prefix of the sproc (kinda usp_GetEmployee)</font></font><br />
<font color="#0000ff">SET </font>@TablePrefix = <font color="#ff0000">'' </font><font color="#808000">-- table prefix, if a table has a prefix (<strong>dt_</strong>)</font><br />
<font color="#0000ff">SET </font>@TableName = <font color="#ff0000">'dt_Employee'</font><br />
<font color="#0000ff">SET </font>@IncludeTabulation = 1  <font color="#808000">-- are we gonna generate paginating and sorting staff (see <a href="http://kostikov.co.uk/blog/?p=3" title="pagination and sorting in ms sql 2000">previous post</a>)</font><br />
<font color="#0000ff">SET </font>@CreateSaveAndAddTogether = 0 <font color="#808000">-- there is an option to generate one sproc for inserting and updating</font></p>
<p>This script has its limitation though. Currently a table for wich we are going to generate sprocs has to have an integer primary key.</p>
<p>files: <a href="http://kostikov.co.uk/blog/wp-content/uploads/2008/03/generatesprocs.sql" title="Generate Sprocs">Generate Sprocs</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kostikov.co.uk/blog/?feed=rss2&amp;p=5</wfw:commentRss>
		</item>
	</channel>
</rss>
