<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Seree Woradechjamroen &#187; c#</title>
	<atom:link href="http://www.iamseree.com/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.iamseree.com</link>
	<description>Keep learning everyday, willing to win and take action</description>
	<lastBuildDate>Fri, 23 Jul 2010 16:58:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Prevent your .NET application from SQL Injection</title>
		<link>http://www.iamseree.com/application-development/prevent-your-net-application-from-sql-injection/</link>
		<comments>http://www.iamseree.com/application-development/prevent-your-net-application-from-sql-injection/#comments</comments>
		<pubDate>Mon, 03 Sep 2007 12:53:56 +0000</pubDate>
		<dc:creator>Seree</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sql injection]]></category>
		<category><![CDATA[vb.net]]></category>

		<guid isPermaLink="false">http://www.iamseree.com/?p=19</guid>
		<description><![CDATA[Hello everyone, Now I&#8217;ll talking about a technique that script kiddies widely used to attack to the first wall of your application. If you&#8217;re a rookie for security topics on development then you may never heard about this before. In my .NET courses training experiences, most of my trainees never know about this issue before ...]]></description>
			<content:encoded><![CDATA[<p>Hello everyone,</p>
<p>Now I&#8217;ll talking about a technique that script kiddies widely used to attack to the first wall of your application. If you&#8217;re a rookie for security topics on development then you may never heard about this before. In my .NET courses training experiences, most of my trainees never know about this issue before and they feel very surprises when I&#8217;ve hacked into their system in no time.</p>
<p><strong><span style="text-decoration: underline;">What is SQL injection?</span></strong></p>
<p>Straightly, It&#8217;s something like you try to inject some unexpected characters into SQL querying process to gain the out-of-case result.</p>
<p>Let&#8217;s see it in more detail!</p>
<p>What should you do If you want to coding your application to authenticate user&#8217;s credential that kept in database?</p>
<p>So easy, right? I&#8217;m just querying the result from database with this simple SQL query and a few line of code.</p>
<blockquote><p>Dim strSQL As String = &#8220;Select COUNT(*) From Members WHERE LoginName=&#8217;&#8221; &amp; txtLoginName.Text &amp; &#8220;&#8216; AND Password=&#8217;&#8221; &amp; txtPassword.Text &amp; &#8220;&#8216;&#8221;</p>
<p>Dim cmd As New SqlCommand(strSQL, con)</p>
<p>cmd.ExecuteScalar()</p></blockquote>
<p>It works perfectly! but how the it&#8217;ll handle if a hard core user input something unexpected into login name just like the following</p>
<blockquote><p>xyz&#8217; OR &#8217;1&#8242;=&#8217;1</p></blockquote>
<p>When it concatenate into SQL string. It&#8217;ll result in to&#8230;<span id="more-19"></span></p>
<blockquote><p>Select COUNT(*) From Members<br />
WHERE LoginName=&#8217;<span style="color: #ff0000;">xyz&#8217; OR &#8217;1&#8242;=&#8217;1</span>&#8216; AND Password=&#8217;<span style="color: #ff0000;">1234</span>&#8216;</p></blockquote>
<p>Yeah, you can see that <em><span style="color: #ff0000;">OR &#8217;1&#8242;=&#8217;1&#8242;</span></em> which always result in TRUE. So, the hard core user can authenticate to the application without knowing of any user&#8217;s login name or password.</p>
<p><!--adsense--></p>
<p><strong><span style="text-decoration: underline;">How can I prevent SQL injection?</span></strong></p>
<p>Yeah, it&#8217;s very easy to do. Just use the technique named as &#8220;Parameterized Query&#8221;.</p>
<p>OMG! What&#8217;s about it? I never heard about those &#8220;Parameterized Query&#8221;.<br />
You get me in trouble again!</p>
<p>Not that serious, It&#8217;s very easy to implement this technique as .NET alraedy provide the framework for you. Just do the following two steps.</p>
<p>1. When you want to create the dynamic SQL query string just like this case. You should use parameter instead of concatenate the variables yourself.</p>
<blockquote><p>Select COUNT(*) From Members WHERE LoginName=<span style="color: #ff0000;">@LoginName</span> AND Password=<span style="color: #ff0000;">@Pwd</span></p></blockquote>
<p>We call <span style="color: #ff0000;">@LoginName</span> and <span style="color: #ff0000;">@Pwd</span> as parameter.</p>
<p>2. Before executing the command. Please specify the value for each parameter first.</p>
<blockquote><p>cmd.Parameters.AddWithValue(&#8220;<span style="color: #ff0000;">@LoginName</span>&#8220;, txtLoginName.Text)</p>
<p>cmd.Parameters.AddWithValue(&#8220;<span style="color: #ff0000;">@Pwd</span>&#8220;, txtPassword.Text)</p>
<p>cmd.ExecuteScalar()</p></blockquote>
<p>When the command was executed. All parameters will be transformed into the value that suitable for the data type of those database. The good things you get here is that. For string (varchar) data type, generally it should open and close with single quote &#8221; &#8216; &#8220;. (You can see this code of the first code block) But not for parameterized query, as it will do automatically internal. So, you don&#8217;t have to pay your attention to those data type symbol for each database. (Especially datetime data type) and another point, the generated SQL query will never been attacked by SQL injection anymore as it know now how to handle those type of technique.</p>
<p>This is all about that!</p>
<p>For more information about SQL injection, please <a href="http://en.wikipedia.org/wiki/SQL_Injection" target="_blank">visit here</a>.</p>
<p><!--adsense--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iamseree.com/application-development/prevent-your-net-application-from-sql-injection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VB.NET vs C# &#8211; Who will win?</title>
		<link>http://www.iamseree.com/application-development/vbnet-vs-c-who-will-win/</link>
		<comments>http://www.iamseree.com/application-development/vbnet-vs-c-who-will-win/#comments</comments>
		<pubDate>Thu, 28 Jun 2007 06:45:32 +0000</pubDate>
		<dc:creator>Seree</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.iamseree.com/?p=10</guid>
		<description><![CDATA[Hi all, This is my first post on blog about Microsoft .NET development. So, let me say a little sorry about my bad English. Let&#8217;s go to those day that C/C++ language dominating Visual Basic all the time. If I can remember it takes more than ten years now since Visual Basic for DOS (1.0). ...]]></description>
			<content:encoded><![CDATA[<p>Hi all,</p>
<p>This is my first post on blog about Microsoft .NET development. So, let me say a little sorry about my bad English.<br />
Let&#8217;s go to those day that C/C++ language dominating Visual Basic all the time. If I can remember it takes more than ten years now since Visual Basic for DOS (1.0). In this blog I&#8217;ll show the various perspective and conclude about these two languages of choices for developer to be chosen for Microsoft .NET development.</p>
<p>Let&#8217;s take a look after them!</p>
<p><!--adsense--></p>
<p><strong>Comparison begin, who will win?</strong></p>
<p>For Visual Basic, this language had dominated the development community due to it&#8217;s ease of use, short learning curve, rich GUI(s) and many more reasons. As It&#8217;s really easy for people to learn and begin programming in no time!<br />
Personally, I&#8217;ve used Visual Basic since version 3.0. In those time it still using 3.5&#8243; diskettes for setup. The first time I try it, I&#8217;m wondering how they can made GUI programming very easy. But I never use it in any commercial applications as those time the application built from Visual Basic is so slow when comparing to any C++ based compiler. So, I&#8217;m sticking with Borland C++ and Visual C++. A few years quickly passed, I&#8217;ve a chance to try Visual Basic again but now for 5.0. It had been improved so much! Very impresses to me. However, Its performance still generate the reason that I should not use it cause of it&#8217;s so slow when comparing to C++ based. But that time I&#8217;m really think that its WYSIWYG is very good and will increase my productivity significantly. So, I decide to learn it in a little deep details. At last, I still consider to stick with C++ based as the speed really made me sick about it. But now I&#8217;m finding some tools that has a cool WYSIWYG but based on C++. So, now I got a really cool tools. Borland C++ Builder.<br />
I used Borland C++ Builder instead of Microsoft Visual C++ with MFC for a couple of years until what Microsoft said it&#8217;ll be the next generation of software development platform named Microsoft .NET. So, now I got a chance to try again on Visual Basic. Now in version 7.0 aka VB.NET. When compared to C++ application with Win32API it still slow in nature. But the productivity was very high now for .NET. So, I use just a few days to decide to go on .NET platform instead of any Win32API or J2EE platform and using both C# and VB.NET until today.<br />
In my experiences regards on both languages. VB.NET has higher productivity in means of a few line of code and less task effort when developing than C#. So, I call it higher productivity. C# also high productivity but in my opinion, VB.NET is better on this topic. But there are somethings you should know about VB.NET and C# when comparison is begin. I written below as one-by-one&#8230;</p>
<p><strong>Performance<br />
</strong>No one win! as it&#8217;ll produce the same output as based on Microsoft CLR. (Common Language Runtime) So, who think that C# will take ahead from VB.NET on performance. It does not!</p>
<p><strong>Number of line</strong><br />
In my experiences, VB.NET may written less number of line in the same task but in most case It should be equal as they using the same class library.</p>
<p><strong>3rd party components</strong><br />
Equality.</p>
<p><strong>3rd party tools</strong><br />
C# is better as some refactoring/intellisense tools support only for C#.</p>
<p><strong>OOP</strong><br />
Now both of them is fully OOP. In .NET 1.1, VB.NET can&#8217;t do operator overloading but in .NET 2.0, it fully support!</p>
<p><strong>My personal conclusion</strong><br />
For my experiences, I preferred VB.NET on small to medium scale of project but C# for large. As on the internet community, I found many C# developers was better than VB.NET. I should not be 100% but for my idea. I think that VB.NET is easies for learning. So, VB.NET may not clearly understand much about architecture and programming logic. But in case of C#, it may not that case as It&#8217;s a long time well structured from the past.<br />
At last, it up to you and the application will produce a good or bad result will be based on your understanding of problem domain, solution and your logic. So, don&#8217;t bother much about languages!</p>
<p><strong>Clearly no winner between VB.NET and C# but Microsoft!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iamseree.com/application-development/vbnet-vs-c-who-will-win/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
