<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code/Tea/Etc... : Visual Basic</title><link>http://blogs.msdn.com/duncanma/archive/tags/Visual+Basic/default.aspx</link><description>Tags: Visual Basic</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>This blog has moved... notice #2... </title><link>http://blogs.msdn.com/duncanma/archive/2004/09/15/230263.aspx</link><pubDate>Thu, 16 Sep 2004 05:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:230263</guid><dc:creator>Duncanma</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/duncanma/comments/230263.aspx</comments><wfw:commentRss>http://blogs.msdn.com/duncanma/commentrss.aspx?PostID=230263</wfw:commentRss><description>&lt;p&gt;For various reasons, the biggest being my desire to play around with .Text, I've moved my blog to my own server at &lt;a href="http://blogs.duncanmackenzie.net/duncanma" target="_blank"&gt;http://blogs.duncanmackenzie.net/duncanma&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;following the 3 leaf model when they moved, I thought I should post this notice a couple of times...&lt;/em&gt; &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=230263" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/.NET+General/default.aspx">.NET General</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/Personal+Musings/default.aspx">Personal Musings</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/Digital+Music+and+Media/default.aspx">Digital Music and Media</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+C_2300_/default.aspx">Visual C#</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/TechEd/default.aspx">TechEd</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/CSharp+Featured+Team+Posts/default.aspx">CSharp Featured Team Posts</category></item><item><title>This blog has moved...</title><link>http://blogs.msdn.com/duncanma/archive/2004/08/25/220319.aspx</link><pubDate>Wed, 25 Aug 2004 17:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:220319</guid><dc:creator>Duncanma</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/duncanma/comments/220319.aspx</comments><wfw:commentRss>http://blogs.msdn.com/duncanma/commentrss.aspx?PostID=220319</wfw:commentRss><description>&lt;p&gt;For various reasons, the biggest being my desire to play around with .Text, I've moved my blog to my own server at &lt;a href="http://blogs.duncanmackenzie.net" target="_blank"&gt;http://blogs.duncanmackenzie.net&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.duncanmackenzie.net/duncanma/archive/2004/08/25/589.aspx" target="_blank"&gt;The first post over there&lt;/a&gt; shows the app that I wrote last night and then used to copy all of my posts and categories over from this blog to the new location... I'll post the code for that app at some point, as boring as it is...&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=220319" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/.NET+General/default.aspx">.NET General</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/Personal+Musings/default.aspx">Personal Musings</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/Digital+Music+and+Media/default.aspx">Digital Music and Media</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+C_2300_/default.aspx">Visual C#</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/TechEd/default.aspx">TechEd</category></item><item><title>The email I get...</title><link>http://blogs.msdn.com/duncanma/archive/2004/08/23/218779.aspx</link><pubDate>Mon, 23 Aug 2004 08:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:218779</guid><dc:creator>Duncanma</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/duncanma/comments/218779.aspx</comments><wfw:commentRss>http://blogs.msdn.com/duncanma/commentrss.aspx?PostID=218779</wfw:commentRss><description>&lt;p&gt;Every day I get from 1 to 10 emails asking me various VB questions... some I answer by pointing to a link, some by providing code, and sometimes I just point people to the newsgroups or forums that exist for this type of question... but this time I thought I'd just post the question and answer into my blog ...&lt;/p&gt;
&lt;br /&gt;
The Question (edited slightly):&lt;br /&gt;
&lt;blockquote&gt;
I just want to ask how to make the string in to proper format..&lt;br /&gt;
ex...&lt;br /&gt;
input.&lt;br /&gt;
gerald&lt;br /&gt;
&lt;br /&gt;
this must be the output:&lt;br /&gt;
Gerald&lt;br /&gt;
&lt;br /&gt;
and i want it to interactively change when i'm inputing a string in a textbox..
&lt;/blockquote&gt;

&lt;p&gt;And the answer is to put this code into the TextChanged event of your textbox;&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;
&lt;font color="Blue" family="Microsoft Sans Serif"&gt;Dim&lt;/font&gt; ci &lt;font color="Blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; Globalization.CultureInfo = _
    System.Threading.Thread.CurrentThread.CurrentCulture&lt;br /&gt;
&lt;br /&gt;
&lt;font color="Blue" family="Microsoft Sans Serif"&gt;Private&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Sub&lt;/font&gt; TextBox1_TextChanged(&lt;font color="Blue" family="Microsoft Sans Serif"&gt;ByVal&lt;/font&gt; sender &lt;font color="Blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; System.&lt;font color="Blue" family="Microsoft Sans Serif"&gt;Object&lt;/font&gt;, _&lt;br /&gt;
        &lt;font color="Blue" family="Microsoft Sans Serif"&gt;ByVal&lt;/font&gt; e &lt;font color="Blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; System.EventArgs) &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Handles&lt;/font&gt; TextBox1.TextChanged&lt;br /&gt;
    &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Dim&lt;/font&gt; pos &lt;font color="Blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Integer&lt;/font&gt; = TextBox1.SelectionStart&lt;br /&gt;
    TextBox1.Text = ci.TextInfo.ToTitleCase(TextBox1.Text)&lt;br /&gt;
    &lt;font color="Blue" family="Microsoft Sans Serif"&gt;If&lt;/font&gt; pos &gt; 0 &lt;font color="Blue" family="Microsoft Sans Serif"&gt;AndAlso&lt;/font&gt; pos &amp;lt;= TextBox1.Text.Length &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Then&lt;/font&gt;&lt;br /&gt;
        TextBox1.SelectionStart = pos&lt;br /&gt;
    &lt;font color="Blue" family="Microsoft Sans Serif"&gt;End&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;If&lt;/font&gt;&lt;br /&gt;
&lt;font color="Blue" family="Microsoft Sans Serif"&gt;End&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Sub&lt;/font&gt;&lt;br /&gt;
&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;The key is that the &lt;b&gt;&lt;a href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemGlobalizationCultureInfoClassTopic.asp" target="_blank"&gt;CultureInfo&lt;/a&gt; &lt;/b&gt;class provides a &lt;b&gt;&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemglobalizationtextinfoclasstopic.asp" target="_blank"&gt;TextInfo&lt;/a&gt; &lt;/b&gt;instance, which in turn has a method of "&lt;b&gt;ToTitleCase&lt;/b&gt;" on it... &lt;a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;312897#3" target="_blank"&gt;This KB article&lt;/a&gt; provides more info and also shows an alternate method to achieve the same results (&lt;b&gt;StrConv()&lt;/b&gt;). &lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=218779" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+Basic/default.aspx">Visual Basic</category></item><item><title>Another article preview up... this one is a content rotator for ASP.NET</title><link>http://blogs.msdn.com/duncanma/archive/2004/08/12/213350.aspx</link><pubDate>Thu, 12 Aug 2004 09:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:213350</guid><dc:creator>Duncanma</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/duncanma/comments/213350.aspx</comments><wfw:commentRss>http://blogs.msdn.com/duncanma/commentrss.aspx?PostID=213350</wfw:commentRss><description>As I discussed in &lt;a href="http://weblogs.asp.net/duncanma/archive/2004/08/05/209654.aspx" target="_blank"&gt;an earlier post&lt;/a&gt;, I wanted to know if people found preview articles useful... and at least a few people said they did, so here is another one....&lt;br /&gt;
&lt;blockquote&gt;
&lt;b&gt;&lt;a href="http://www.duncanmackenzie.net/writing/Previews/ContentRotator/default.aspx" target="_blank"&gt;Rotating Is Fun
&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Summary:&lt;/b&gt; Duncan Mackenzie describes the creation of a simple &amp;lsquo;content rotator&amp;rsquo; in ASP.NET
&lt;/blockquote&gt;
Feedback, via the blog or the feedback link at the bottom of &lt;a href="http://www.duncanmackenzie.net/writing/Previews/ContentRotator/default.aspx" target="_blank"&gt;the article page&lt;/a&gt;, is always welcome!&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=213350" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+Basic/default.aspx">Visual Basic</category></item><item><title>vbCity has blogs!?!? Excellent...</title><link>http://blogs.msdn.com/duncanma/archive/2004/08/12/213338.aspx</link><pubDate>Thu, 12 Aug 2004 09:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:213338</guid><dc:creator>Duncanma</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/duncanma/comments/213338.aspx</comments><wfw:commentRss>http://blogs.msdn.com/duncanma/commentrss.aspx?PostID=213338</wfw:commentRss><description>&lt;p&gt;Serge Baranovsky, the man behind &lt;a href="http://vbcity.com/" target="_blank"&gt;vbCity&lt;/a&gt;, just mentioned to me that they have started hosting blogs... just their staff at the moment, but they have plans to grow... Since vbCity is already one of the best sites for VB developers, this is good news!&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.vbcity.com/" target="_blank"&gt;http://blogs.vbcity.com/&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=213338" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+Basic/default.aspx">Visual Basic</category></item><item><title>The Updater Application Block... various additions...</title><link>http://blogs.msdn.com/duncanma/archive/2004/08/10/211711.aspx</link><pubDate>Tue, 10 Aug 2004 08:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:211711</guid><dc:creator>Duncanma</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/duncanma/comments/211711.aspx</comments><wfw:commentRss>http://blogs.msdn.com/duncanma/commentrss.aspx?PostID=211711</wfw:commentRss><description>&lt;p&gt;One of the nice things about &lt;a href="http://www.gotdotnet.com/Community/Workspaces/workspace.aspx?id=83c68646-befb-4586-ba9f-fdf1301902f5"&gt;the Updater Application Block&lt;/a&gt; is that it was written to be quite extensible... I saw &lt;a href="http://www.gotdotnet.com/Community/MessageBoard/Thread.aspx?id=251828&amp;Page=1#252347"&gt;a post today &lt;/a&gt;where SamSantiago mentioned &lt;a href="http://www.softitechture.com/discussions/"&gt;he had created a custom class&lt;/a&gt; to delete all those old versions on your machine whenever you do an update.... very cool, I'll be trying that out right away... &lt;/p&gt;

&lt;p&gt;Personally, I've &lt;i&gt;updated the updater&lt;/i&gt; in &lt;a href="http://weblogs.asp.net/duncanma/archive/2003/08/12/23901.aspx"&gt;a few different ways&lt;/a&gt;, but the most recent changes have been the most reusable, in my opinon;&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;I fixed the code so that it no longer requires users to have admin rights...&lt;/li&gt;
&lt;li&gt;I added a 'mandatory' flag to the updates (and updated the manifestutility in a few different ways), so that for some updates the client app would know not to ask the user if they want to upgrade... great for occasionally forcing everyone up to the same build...&lt;/li&gt;
&lt;li&gt;and I modified the manifest retrieval code so that it can call an ASP or ASP.NET page, which in turn allowed me to create a manifest.aspx page that returns different manifests based on the user's credentials (so I can have a 'beta' group who are given one version, and everyone else gets the last major release...)&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;I've got to work out a way to get these bits of code online.... it isn't hard, but it takes time that I haven't planned in yet :)&lt;/p&gt;

&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=211711" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+C_2300_/default.aspx">Visual C#</category></item><item><title>Soma discusses the future of VB</title><link>http://blogs.msdn.com/duncanma/archive/2004/08/08/211093.aspx</link><pubDate>Mon, 09 Aug 2004 06:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:211093</guid><dc:creator>Duncanma</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/duncanma/comments/211093.aspx</comments><wfw:commentRss>http://blogs.msdn.com/duncanma/commentrss.aspx?PostID=211093</wfw:commentRss><description>&lt;a href="http://blogs.msdn.com/somasegar"&gt;Soma&lt;/a&gt; (whose name you may or may not recognize) is in a position to know a lot about the future of Visual Basic (in his own words, from his intro post... &lt;i&gt;"My name is Somasegar and I run the Developer Division at Microsoft."&lt;/i&gt;), so when he decides to post about it, it is probably worth a quick read...

&lt;blockquote&gt;&lt;i&gt;....A couple of the people in that session had some questions for me around our commitment to VB in the .NET world.  I was a little surprised by these questions.  That made me think more and I wanted to share with you my thoughts on this....
&lt;/i&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/somasegar/archive/2004/08/01/204540.aspx"&gt;Read the full post here...&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=211093" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+Basic/default.aspx">Visual Basic</category></item><item><title>Ok... I can finally read my comments again...</title><link>http://blogs.msdn.com/duncanma/archive/2004/08/08/210803.aspx</link><pubDate>Sun, 08 Aug 2004 09:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:210803</guid><dc:creator>Duncanma</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/duncanma/comments/210803.aspx</comments><wfw:commentRss>http://blogs.msdn.com/duncanma/commentrss.aspx?PostID=210803</wfw:commentRss><description>&lt;p&gt;I'm sure I'll be one of many commenting on this, but &lt;A href="http://weblogs.asp.net/sitenews/archive/2004/08/07/210728.aspx"&gt;the recent updates to .Text on this site &lt;/a&gt;are a wonderful improvement. For the past while I had been unable to really sift out the good comments from the bad, so real (non-spam) comments to the VB or C# FAQ sites, and to this blog... were all being drowned out by all of the spam. Keeping up with it (to delete the spam) was almost impossible and I gave up some time ago ... &lt;/p&gt; &lt;p&gt;We'll see how it goes, but I'm hoping these changes make&amp;nbsp;these blogs sites&amp;nbsp;a less attractive target for spam.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=210803" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/Personal+Musings/default.aspx">Personal Musings</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+C_2300_/default.aspx">Visual C#</category></item><item><title>Previews of articles...</title><link>http://blogs.msdn.com/duncanma/archive/2004/08/05/209654.aspx</link><pubDate>Fri, 06 Aug 2004 06:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:209654</guid><dc:creator>Duncanma</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/duncanma/comments/209654.aspx</comments><wfw:commentRss>http://blogs.msdn.com/duncanma/commentrss.aspx?PostID=209654</wfw:commentRss><description>&lt;p&gt;A couple of weeks ago I posted &lt;a href="http://msdn.microsoft.com/vbasic/default.aspx?pull=/library/en-us/dncodefun/html/code4fun08032004.asp"&gt;my "Quick Poll" Coding 4 Fun column &lt;/a&gt;in its unedited form... was that useful?&lt;br /&gt;&lt;br /&gt;If it was, I can continue to do that with my articles ... basically posting my version of them up in advance onto &lt;a href="http://www.duncanmackenzie.net"&gt;www.duncanmackenzie.net&lt;/a&gt; and then redirecting that to the real article once it ends up on MSDN.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=209654" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/Personal+Musings/default.aspx">Personal Musings</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+C_2300_/default.aspx">Visual C#</category></item><item><title>Jesse Liberty, author of one of my favorite books (Clouds to Code) gives an overview of "My" in Visual Basic 2005</title><link>http://blogs.msdn.com/duncanma/archive/2004/08/05/208646.aspx</link><pubDate>Thu, 05 Aug 2004 07:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:208646</guid><dc:creator>Duncanma</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/duncanma/comments/208646.aspx</comments><wfw:commentRss>http://blogs.msdn.com/duncanma/commentrss.aspx?PostID=208646</wfw:commentRss><description>Blurb copied using the cool "Blog This" link on the ondotnet pages :)
&lt;blockquote&gt;&lt;p&gt;&lt;a href="http://www.ondotnet.com/pub/a/dotnet/2004/08/02/libertywhidbey.html"&gt;Rapid Application Development with VB.NET 2.0&lt;/a&gt; by Jesse Liberty -- For a couple of years now, Jesse Liberty been touting the Microsoft endorsed-sentiment that it really doesn't matter if you program in C# or in VB.NET, since both are just syntactic sugar layered on top of MSIL (Microsoft Intermediate Language, the true language of .NET). That appears to be changing a bit with Whidbey. Jesse Liberty investigates the new My object in VB.NET 2.0.&lt;/p&gt;&lt;/blockquote&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=208646" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+Basic/default.aspx">Visual Basic</category></item><item><title>Updated the headlines on the VB Community page today...</title><link>http://blogs.msdn.com/duncanma/archive/2004/08/02/206201.aspx</link><pubDate>Mon, 02 Aug 2004 21:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:206201</guid><dc:creator>Duncanma</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/duncanma/comments/206201.aspx</comments><wfw:commentRss>http://blogs.msdn.com/duncanma/commentrss.aspx?PostID=206201</wfw:commentRss><description>&lt;P&gt;&lt;A href="http://msdn.microsoft.com/vbasic/community"&gt;http://msdn.microsoft.com/vbasic/community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I added a little blurb at the top asking folks to send in any ideas they have for this page, please use it... I try to scan the community sites regularly but I'm certainly missing a lot of stuff.&lt;/P&gt;&lt;P&gt;If you see something worth noting on the VB site, let me know.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=206201" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+Basic/default.aspx">Visual Basic</category></item><item><title>New Coding 4 Fun Article up...</title><link>http://blogs.msdn.com/duncanma/archive/2004/07/28/200228.aspx</link><pubDate>Wed, 28 Jul 2004 22:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:200228</guid><dc:creator>Duncanma</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/duncanma/comments/200228.aspx</comments><wfw:commentRss>http://blogs.msdn.com/duncanma/commentrss.aspx?PostID=200228</wfw:commentRss><description>&lt;P&gt;&lt;A href="http://msdn.microsoft.com/vbasic/using/columns/code4fun/default.aspx?pull=/library/en-us/dncodefun/html/code4fun08032004.asp"&gt;Add a Quick Poll to Your Web Site&lt;/A&gt;&lt;BR&gt;&lt;STRONG&gt;Summary:&lt;/STRONG&gt; Duncan Mackenzie describes his process to build a "Quick Poll" using Visual Basic and ASP.NET.&lt;/P&gt;&lt;P&gt;Recent discussions have motivated me to add some 'anti-repeat-voting' code to this sample... I've finished up most of the changes, so grab the sample from the article if you are interested and then watch this space for more information on the additions!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=200228" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/Personal+Musings/default.aspx">Personal Musings</category></item><item><title>Solutions at a Glance... great for all .NET developers interested in security...</title><link>http://blogs.msdn.com/duncanma/archive/2004/07/26/197713.aspx</link><pubDate>Mon, 26 Jul 2004 23:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:197713</guid><dc:creator>Duncanma</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/duncanma/comments/197713.aspx</comments><wfw:commentRss>http://blogs.msdn.com/duncanma/commentrss.aspx?PostID=197713</wfw:commentRss><description>&lt;P&gt;I was just talking with J.D. Meier (&lt;A href="http://www.microsoft.com/practices"&gt;from PAG&lt;/A&gt;) about &lt;A href="http://msdn.microsoft.com/library/en-us/dnnetsec/html/ThreatCounter.asp"&gt;the Improving Application Security&lt;/A&gt; book and he pointed out a great page to me... the "&lt;A href="http://msdn.microsoft.com/library/en-us/dnnetsec/html/THCMGlance.asp"&gt;Solutions At A Glance&lt;/A&gt;" list... this page lists a ton of very frequently asked questions around .NET security and provides links deep into all that great PAG security info.&lt;/P&gt;&lt;P&gt;Some examples;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;B&gt;How to write secure managed code&lt;/B&gt; &lt;/P&gt;&lt;P&gt;Use strong names to digitally sign your assemblies and to make them tamperproof. At the&amp;nbsp;same time you need to be aware of strong name issues when you use strong name assemblies with ASP.NET. Reduce your assembly attack profile by adhering to solid object oriented design principles, and then use code access security to further restrict which code can call your code. Use structured exception handling to prevent sensitive information from propagating beyond your current trust boundary and to develop more robust code. Avoid canonicalization issues, particularly with input file names and URLs. &lt;P&gt;For information about how to improve the security of your managed code, see Chapter 7, "&lt;A href="http://msdn.microsoft.com/library/en-us/dnnetsec/html/THCMCh07.asp"&gt;Building Secure Assemblies&lt;/A&gt;." For more information about how to use&amp;nbsp;code access security effectively to further improve security, see Chapter 8, "&lt;A href="http://msdn.microsoft.com/library/en-us/dnnetsec/html/THCMCh08.asp"&gt;Code Access Security in Practice&lt;/A&gt;." For information about performing managed code reviews, see Chapter 21, "&lt;A href="http://msdn.microsoft.com/library/en-us/dnnetsec/html/THCMCh21.asp"&gt;Code Review&lt;/A&gt;." &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;and&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;B&gt;How to prevent SQL injection&lt;/B&gt; &lt;/P&gt;&lt;P&gt;Use parameterized stored procedures for data access. The use of parameters ensures that input values are checked for type and length. Parameters are also treated as safe literal values and not executable code within the database. If you cannot use stored procedures, use SQL statements with parameters. Do not build SQL statements by concatenating input values with SQL commands. Also, ensure that your application uses a least privileged database login to constrain its capabilities in the database. &lt;P&gt;For more information about SQL injection and for further countermeasures, see "SQL Injection" in Chapter 14, "&lt;A href="http://msdn.microsoft.com/library/en-us/dnnetsec/html/THCMCh14.asp"&gt;Building Secure Data Access&lt;/A&gt;." &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;For a ton more questions and answers, you can check out the entire page &lt;A href="http://msdn.microsoft.com/library/en-us/dnnetsec/html/THCMGlance.asp" target=_blank&gt;here&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=197713" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+C_2300_/default.aspx">Visual C#</category></item><item><title>Thanks Bill... Vaughn that is, not that other guy...</title><link>http://blogs.msdn.com/duncanma/archive/2004/07/21/190909.aspx</link><pubDate>Thu, 22 Jul 2004 06:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:190909</guid><dc:creator>Duncanma</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/duncanma/comments/190909.aspx</comments><wfw:commentRss>http://blogs.msdn.com/duncanma/commentrss.aspx?PostID=190909</wfw:commentRss><description>&lt;P&gt;I noticed yesterday that my poll wasn't showing the question on the top of the list of choices, or the list of results. Viewing the source made it pretty obvious the &amp;lt;asp:label&amp;gt; was rendering, but that it was empty. Checking my code everything seemed fine, but when I retrieved the poll details through a Stored Proc I was using an Output param for the question text and it was always blank.&amp;nbsp;Well, I knew there was an entire article on MSDN on this exact topic... and a quick search on &amp;#8220;Vaughn&amp;#8221; on MSDN took me right to the article I knew would show me exactly what I needed to do.&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;H4&gt;&lt;A href="http://msdn.microsoft.com/vbasic/default.aspx?pull=/library/en-us/dnadonet/html/gazoutas.asp"&gt;Retrieving the Gazoutas: Understanding SQL Server Return Codes and Output Parameters&lt;/A&gt;&lt;/H4&gt;
&lt;P&gt;William Vaughn&lt;BR&gt;&lt;B&gt;&lt;BR&gt;Summary:&lt;/B&gt; Discusses how to capture, interrupt, and handle resultsets and rowsets, as well as the extra information that they return when executing a Microsoft SQL Server query. (7 printed pages)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yep... turns out I had goofed up, I was calling the stored proc with ExecuteReader, but I was trying to read those params before I had closed the data reader. So I made one change to my code;&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;PRE&gt;&lt;FONT color=blue family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; dr &lt;FONT color=blue family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; SqlDataReader = _
    cmdGetPollDetails.ExecuteReader( _
    CommandBehavior.CloseConnection)
&lt;FONT color=blue family="Microsoft Sans Serif"&gt;If&lt;/FONT&gt; dr.HasRows &lt;FONT color=blue family="Microsoft Sans Serif"&gt;Then&lt;/FONT&gt;
    &lt;FONT color=blue family="Microsoft Sans Serif"&gt;Dim&lt;/FONT&gt; po &lt;FONT color=blue family="Microsoft Sans Serif"&gt;As&lt;/FONT&gt; PollOption
    &lt;FONT color=blue family="Microsoft Sans Serif"&gt;Do&lt;/FONT&gt; &lt;FONT color=blue family="Microsoft Sans Serif"&gt;While&lt;/FONT&gt; dr.Read
        po = &lt;FONT color=blue family="Microsoft Sans Serif"&gt;New&lt;/FONT&gt; PollOption
        po.OptionID = dr.GetInt32(0)
        po.OptionText = dr.GetString(1)
        result.Options.&lt;FONT color=blue family="Microsoft Sans Serif"&gt;Add&lt;/FONT&gt;(po)
    &lt;FONT color=blue family="Microsoft Sans Serif"&gt;Loop&lt;/FONT&gt;
    result.ID = pollID
    result.Name = &lt;FONT color=blue family="Microsoft Sans Serif"&gt;CStr&lt;/FONT&gt;( _
        cmdGetPollDetails.Parameters(&lt;FONT color=red family="Microsoft Sans Serif"&gt;"@PollName"&lt;/FONT&gt;).Value)
    result.Question = &lt;FONT color=blue family="Microsoft Sans Serif"&gt;CStr&lt;/FONT&gt;( _
        cmdGetPollDetails.Parameters(&lt;FONT color=red family="Microsoft Sans Serif"&gt;"@PollQuestion"&lt;/FONT&gt;).Value)
    dr.Close()
    &lt;FONT color=blue family="Microsoft Sans Serif"&gt;Return&lt;/FONT&gt; result
&lt;FONT color=blue family="Microsoft Sans Serif"&gt;Else&lt;/FONT&gt;
    dr.Close()
    &lt;FONT color=blue family="Microsoft Sans Serif"&gt;Return&lt;/FONT&gt; &lt;FONT color=blue family="Microsoft Sans Serif"&gt;Nothing&lt;/FONT&gt;
&lt;FONT color=blue family="Microsoft Sans Serif"&gt;End&lt;/FONT&gt; &lt;FONT color=blue family="Microsoft Sans Serif"&gt;If&lt;/FONT&gt;
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I just moved the dr.Close( ) up to right after the end of the Do loop...&lt;/P&gt;&lt;PRE&gt;    &lt;FONT color=blue family="Microsoft Sans Serif"&gt;Loop&lt;/FONT&gt;
    dr.Close()
    result.ID = pollID
    result.Name = &lt;FONT color=blue family="Microsoft Sans Serif"&gt;CStr&lt;/FONT&gt;( _
        cmdGetPollDetails.Parameters(&lt;FONT color=red family="Microsoft Sans Serif"&gt;"@PollName"&lt;/FONT&gt;).Value)
    result.Question = &lt;FONT color=blue family="Microsoft Sans Serif"&gt;CStr&lt;/FONT&gt;( _
        cmdGetPollDetails.Parameters(&lt;FONT color=red family="Microsoft Sans Serif"&gt;"@PollQuestion"&lt;/FONT&gt;).Value)
    &lt;FONT color=blue family="Microsoft Sans Serif"&gt;Return&lt;/FONT&gt; result
&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=190909" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+Basic/default.aspx">Visual Basic</category></item><item><title>Don't ask me why, but I've become the official forum for Spiderman 2</title><link>http://blogs.msdn.com/duncanma/archive/2004/07/21/190088.aspx</link><pubDate>Wed, 21 Jul 2004 18:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:190088</guid><dc:creator>Duncanma</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/duncanma/comments/190088.aspx</comments><wfw:commentRss>http://blogs.msdn.com/duncanma/commentrss.aspx?PostID=190088</wfw:commentRss><description>&lt;P&gt;I blame google.&lt;/P&gt;&lt;P&gt;(&lt;A href="http://weblogs.asp.net/duncanma/archive/2004/06/30/169950.aspx"&gt;250 + comments so far, not counting the ones I've had to remove&lt;/A&gt;)&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=190088" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/Personal+Musings/default.aspx">Personal Musings</category><category domain="http://blogs.msdn.com/duncanma/archive/tags/Visual+C_2300_/default.aspx">Visual C#</category></item></channel></rss>