<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>VB.NET Guru</title>
	<atom:link href="http://vbguru.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://vbguru.wordpress.com</link>
	<description>My Blog about all the little tricks I do in VB.NET</description>
	<lastBuildDate>Wed, 05 May 2010 03:27:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='vbguru.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>VB.NET Guru</title>
		<link>http://vbguru.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://vbguru.wordpress.com/osd.xml" title="VB.NET Guru" />
	<atom:link rel='hub' href='http://vbguru.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Visual Studio 2010</title>
		<link>http://vbguru.wordpress.com/2010/05/04/visual-studio-2010/</link>
		<comments>http://vbguru.wordpress.com/2010/05/04/visual-studio-2010/#comments</comments>
		<pubDate>Tue, 04 May 2010 16:32:17 +0000</pubDate>
		<dc:creator>Daryl</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://vbguru.wordpress.com/?p=167</guid>
		<description><![CDATA[I am installing visual studio 2010 right now. I&#8217;m excited to try the new database features. I heard directly from a Microsoft source that you won&#8217;t need to use SQL management studio anymore. I hope it&#8217;s true. I&#8217;ve also read that VB.NET can now do EVERYTHING that C# can do. They are now a fully [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=167&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am installing visual studio 2010 right now.  I&#8217;m excited to try the new database features.  I heard directly from a Microsoft source that you won&#8217;t need to use SQL management studio anymore.  I hope it&#8217;s true.  I&#8217;ve also read that VB.NET can now do EVERYTHING that C# can do.  They are now a fully merged language.  I&#8217;m also excited about no longer having to put an underscore (_) at the end of your code line to do line continuation, instead the system recognizes that your line is continuing automatically.  That should be really cool. Now I have even more reasons to brag about how VB is better then C#.  I&#8217;ve always hated semicolons but the C# people would win the argument by saying that line continuation was a hassle in VB, well take that C#, I don&#8217;t need a semicolon or a underscore, my language is smarter then yours! <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbguru.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbguru.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbguru.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbguru.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbguru.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbguru.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbguru.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbguru.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbguru.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbguru.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbguru.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbguru.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbguru.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbguru.wordpress.com/167/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=167&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbguru.wordpress.com/2010/05/04/visual-studio-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f1b1a10278e9d375918280dd0f7347bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Daryl</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Date trick.</title>
		<link>http://vbguru.wordpress.com/2010/02/12/sql-date-trick/</link>
		<comments>http://vbguru.wordpress.com/2010/02/12/sql-date-trick/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 23:39:14 +0000</pubDate>
		<dc:creator>Daryl</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://vbguru.wordpress.com/?p=160</guid>
		<description><![CDATA[You ever have to write a query where you need to show a range of dates, but some of the dates are missing? Most message boards I have read want you to create some massive date table to keep track of every day and then you can use it in a join to get the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=160&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You ever have to write a query where you need to show a range of dates, but some of the dates are missing? Most message boards I have read want you to create some massive date table to keep track of every day and then you can use it in a join to get the missing days.  Well I came up with my own solution to this,  I&#8217;ve seen variations of it out there but none quite like mine. I created a function that you pass in a start date and an end date, and it returns all the dates in the middle.  It also uses a SQL while loop much like you&#8217;d use a &#8216;FOR LOOP&#8217; in code, which I think is pretty nifty. I also included a line to get rid of weekend dates, depending on the data you are using you may or may not want to do this. In the actual function it takes in the parameters for the dates, I wrote it this way so you can just copy and paste it into a SQL Query tool and see the magic.</p>
<pre class="brush: sql;">

declare @StartDate datetime;
declare @EndDate datetime;

DECLARE @TMP_DATES AS TABLE

(
	[Date] datetime
)

SET @StartDate = GETDATE()
SET @EndDate = @StartDate+14

 declare @i int
 SET @i = 0;
 while (@i&lt;(DATEDIFF (d, @StartDate, @EndDate)))
 begin
 insert into @TMP_DATES values (CONVERT(CHAR(10),@StartDate+@i,101))
 SET @i=@i+1
 end

DELETE from @TMP_DATES where DATEPART(weekday,[Date]) = 1 OR DATEPART(weekday,[Date]) = 7

SELECT * from @TMP_DATES
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbguru.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbguru.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbguru.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbguru.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbguru.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbguru.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbguru.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbguru.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbguru.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbguru.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbguru.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbguru.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbguru.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbguru.wordpress.com/160/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=160&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbguru.wordpress.com/2010/02/12/sql-date-trick/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f1b1a10278e9d375918280dd0f7347bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Daryl</media:title>
		</media:content>
	</item>
		<item>
		<title>Programmer Interviews</title>
		<link>http://vbguru.wordpress.com/2010/01/20/programmer-interviews/</link>
		<comments>http://vbguru.wordpress.com/2010/01/20/programmer-interviews/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 03:07:34 +0000</pubDate>
		<dc:creator>Daryl</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://vbguru.wordpress.com/?p=150</guid>
		<description><![CDATA[It is interesting to me how people evaluate programmers. I have applied for many programming jobs over my life time and I usually run into one of three scenarios: 1) I&#8217;ll start with my favorite, they have me write code. This is my absolute favorite type of interview, every time I get this one I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=150&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It is interesting to me how people evaluate programmers.  I have applied for many programming jobs over my life time and I usually run into one of three scenarios:</p>
<p>1) I&#8217;ll start with my favorite, they have me write code.</p>
<p>This is my absolute favorite type of interview, every time I get this one I always get the job offer.  They give me a problem and ask me to write code to solve it.  Not on a white board, or in pseudo code, but on a PC with Visual Studio installed. The last one I did like this they wanted me to connect through a web service to a SQL database, download some information, save it locally on the PC, modify it, and send it back via the web service to be recored with the new value.   </p>
<p>So not only did I write code to do it, I also wrote a design document, added complex error handling, and I did it on a PC without internet access (no help form the web).  They hired me and later told me that none of the other applicants even finished the code. </p>
<p>2) The Programmer Talk Interview.</p>
<p>I like this one too, I sit down with one of the other developers on the team and we talk about design best practices,  software development methodology, and applications that I have worked on before. This type of interview I usually do good with as well, but other times it has gone poorly when I&#8217;m not on the same page.</p>
<p>3) The Computer Class Questions. (Ugh!)</p>
<p>This is the type I hate.  They ask you to write a linked list optimizer or an anagram solver while your on the phone or on a white board.  This may be great for those of you out there that got a 4.0 in all your computer classes (which actually I did get a 4.0 in programming II), but I don&#8217;t see how it says anything about your actual ability to solve problems. When I write code, I solve problems.  I have written code that connects to a semi-truck over a serial port found under the dash with no documentation on the communication protocol which 4 other programmers had tried and failed.  I did it, and I even had to re-write a C++ driver in .NET and my .NET driver ran faster.  I bet if the company I was working at at the time had given me a question about linked lists they would have never figured out how to get it to work.</p>
<p>When I interview programmers, I use method 1 above.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbguru.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbguru.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbguru.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbguru.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbguru.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbguru.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbguru.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbguru.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbguru.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbguru.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbguru.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbguru.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbguru.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbguru.wordpress.com/150/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=150&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbguru.wordpress.com/2010/01/20/programmer-interviews/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f1b1a10278e9d375918280dd0f7347bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Daryl</media:title>
		</media:content>
	</item>
		<item>
		<title>VB vs C#</title>
		<link>http://vbguru.wordpress.com/2010/01/05/vb-vs-c/</link>
		<comments>http://vbguru.wordpress.com/2010/01/05/vb-vs-c/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 17:44:59 +0000</pubDate>
		<dc:creator>Daryl</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://vbguru.wordpress.com/?p=148</guid>
		<description><![CDATA[So I thought that I would throw my opinion out into the C# vs VB.NET debate. Let me say that professionally I have had to program in both languages on a scale of 1 to 10 my skills in VB are a solid 10, but in C# I&#8217;d only consider myself a 6 or 7. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=148&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So I thought that I would throw my opinion out into the C# vs VB.NET debate.  Let me say that professionally I have had to program in both languages on a scale of 1 to 10 my skills in VB are a solid 10, but in C# I&#8217;d only consider myself a 6 or 7.  The thing I usually say when people ask me if I like C# is &#8220;No, There are too many semicolons.&#8221; It&#8217;s funny to me and usually to whomever I&#8217;m talking to. But really I have yet to run into a scenario where there is something you can do in C# but you can&#8217;t in VB. There are a number of translators on the internet that will translate back and forth from C# to VB and vise versa. So whenever I have to write in C# if I get stuck I write the code out in VB and then translate it to C#.  </p>
<p>Since it is easy to call a C# DLL from VB and vise versa, personally I think it does not matter what language you write in.  If you have a good multi-tiered architecture you should be able to let one programmer write his tier in VB and another tier in C#, but I have yet to be at a company who thinks this is a good idea.  I&#8217;m not sure why I guess it&#8217;s adding a layer of complexity that project managers do not understand or want to deal with. </p>
<p>So at the end of the day my opionion is that both languages are equal, and you should just write in whatever language you like.  I have been writing in BASIC code my entire life, and switching over to C# just seems pointless to me, unless there is a paycheck in it.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbguru.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbguru.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbguru.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbguru.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbguru.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbguru.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbguru.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbguru.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbguru.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbguru.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbguru.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbguru.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbguru.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbguru.wordpress.com/148/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=148&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbguru.wordpress.com/2010/01/05/vb-vs-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f1b1a10278e9d375918280dd0f7347bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Daryl</media:title>
		</media:content>
	</item>
		<item>
		<title>Multi-Tiered Architecture</title>
		<link>http://vbguru.wordpress.com/2010/01/01/multi-tiered-architecture/</link>
		<comments>http://vbguru.wordpress.com/2010/01/01/multi-tiered-architecture/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 05:00:00 +0000</pubDate>
		<dc:creator>Daryl</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://vbguru.wordpress.com/?p=23</guid>
		<description><![CDATA[Muti-Tiered Architecture is a very important software concept. Whenever I am givien someone elses code to fix my brain explodes when I see All three of the major teirs in the same function. The three tiers are: Presentation, Application, and Database. In my opinion these three areas should never mix. Your UI should never call [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=23&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Muti-Tiered Architecture is a very important software concept. Whenever I am givien someone elses code to fix my brain explodes when I see All three of the major teirs in the same function.  The three tiers are: Presentation, Application, and Database. In my opinion these three areas should never mix.  Your UI should never call the database, and your Application Layer should never interact with the UI.  Sometimes you will find yourself in a situation where you have to do some business logic in the UI or inside that database tier, but you should never, ever have to mix the Presentation with the database.</p>
<p>Personally I prefer what I call a 4 tier model. I break down the Development into 4 distinct Areas:</p>
<p>UI &#8211; (User Interface or Presentation)<br />
BL &#8211; (Business Logic or Application, or I even prefer calling it the Logic Layer)<br />
DL &#8211; (Data Layer)<br />
DB &#8211; (Database)</p>
<p>I break out the database Layer into two parts, the Data Layer, and the Data Base, this is not the actual database that would be a different layer if anything.  The purpose of the data Layer is to convert all database objects into your custom business objects. The database layer only returns datasets, data tables, and other database related objects, but not SQL objects.  The Database Layer uses SQL objects or whatever type of database your are connecting to, but only passes back the common database objects like datatables and the sort.  This allows TRUE database portability.  If you want to change from SQL to mySQL or any other database technology you only have to change one small layer of your code.  Your UI has NO idea that underneath it all there is a SQL database or a mySQL database, or an XML flat file, it does not know, nor does it care.</p>
<p>I allways create a common library that has the base objects that I use to transfer data.  I use the namespace &#8216;common&#8217;.  So I use somthing like &#8216;vbguru.Common.User&#8217; as my common user object. This way all layers can have access to a common object and pass data back and forth using it.  I also separate my tiers into at least different files, I don&#8217;t mix tiers in one code file, I even prefer to put them into their own projects for what I would call &#8216;ultimate portability.&#8217;  By breaking down your logic into small chunks it makes it easier to reuse.  I love the idea of perfecting some logic and creating a DLL and never looking at it&#8217;s code again, just add it to a new project as the dll.</p>
<p>Here is an example of some good muti-tiered code.  I am putting it all in one file so that it is easy to read here. Normally, I would put each piece in it&#8217;s own file.</p>
<div style="font-family:Courier New;font-size:10pt;color:black;background:white;">
<p style="margin:0;"><span style="color:blue;">Namespace</span> vbGuru</p>
<p style="margin:0;">&nbsp; <span style="color:blue;">Public</span> <span style="color:blue;">Class</span> UI</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">Public</span> <span style="color:blue;">Sub</span> UI_Function()</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:blue;">Dim</span> Obj <span style="color:blue;">As</span> vbGuru.Common.MyData()</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:blue;">Dim</span> AL <span style="color:blue;">As</span> vbGuru.Logic = <span style="color:blue;">New</span> vbGuru.Logic</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; Obj = AL.GetObj</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:green;">&#8216;Add UI Stuff</span></p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">End</span> <span style="color:blue;">Sub</span></p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; <span style="color:blue;">End</span> <span style="color:blue;">Class</span></p>
<p style="margin:0;"><span style="color:blue;">End</span> <span style="color:blue;">Namespace</span></p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;"><span style="color:blue;">Namespace</span> vbGuru.Common</p>
<p style="margin:0;">&nbsp; <span style="color:blue;">Public</span> <span style="color:blue;">Structure</span> MyData</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">Public</span> id <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">Public</span> Name <span style="color:blue;">As</span> <span style="color:blue;">String</span></p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">Public</span> Value <span style="color:blue;">As</span> <span style="color:blue;">String</span></p>
<p style="margin:0;">&nbsp; <span style="color:blue;">End</span> <span style="color:blue;">Structure</span></p>
<p style="margin:0;"><span style="color:blue;">End</span> <span style="color:blue;">Namespace</span></p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;"><span style="color:blue;">Namespace</span> vbGuru</p>
<p style="margin:0;">&nbsp; <span style="color:blue;">Public</span> <span style="color:blue;">Class</span> Logic</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">Public</span> <span style="color:blue;">Function</span> GetObj() <span style="color:blue;">As</span> vbGuru.Common.MyData()</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:blue;">Dim</span> Data <span style="color:blue;">As</span> vbGuru.Data = <span style="color:blue;">New</span> vbGuru.Data</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:blue;">Dim</span> Obj <span style="color:blue;">As</span> vbGuru.Common.MyData() = Data.GetObj()</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:green;">&#8216;Add any logic that you need to manipulate the object</span></p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:blue;">Return</span> Obj</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">End</span> <span style="color:blue;">Function</span></p>
<p style="margin:0;">&nbsp; <span style="color:blue;">End</span> <span style="color:blue;">Class</span></p>
<p style="margin:0;"><span style="color:blue;">End</span> <span style="color:blue;">Namespace</span></p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;"><span style="color:blue;">Namespace</span> vbGuru</p>
<p style="margin:0;">&nbsp; <span style="color:blue;">Public</span> <span style="color:blue;">Class</span> Data</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">Public</span> <span style="color:blue;">Function</span> GetObj() <span style="color:blue;">As</span> vbGuru.Common.MyData()</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:blue;">Dim</span> DB <span style="color:blue;">As</span> vbGuru.DB = <span style="color:blue;">New</span> vbGuru.DB</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:blue;">Dim</span> dt <span style="color:blue;">As</span> DataTable = DB.GetObj()</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:blue;">If</span> dt <span style="color:blue;">Is</span> <span style="color:blue;">Nothing</span> <span style="color:blue;">Then</span> <span style="color:blue;">Return</span> <span style="color:blue;">Nothing</span></p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:green;">&#8216;I don&#8217;t think this second line is needed</span></p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:green;">&#8216;But I allways put it in just in case.</span></p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:blue;">If</span> dt.Rows.Count = 0 <span style="color:blue;">Then</span> <span style="color:blue;">Return</span> <span style="color:blue;">Nothing</span></p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:blue;">Dim</span> Que <span style="color:blue;">As</span> Queue(<span style="color:blue;">Of</span> vbGuru.Common.MyData) = <span style="color:blue;">New</span> Queue(<span style="color:blue;">Of</span> vbGuru.Common.MyData)</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:green;">&#8216;I like to use Queues to avoid for next loops and i&#8217;s</span></p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:blue;">For</span> <span style="color:blue;">Each</span> drow <span style="color:blue;">In</span> dt.Rows</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:blue;">Dim</span> obj <span style="color:blue;">As</span> vbGuru.Common.MyData</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; obj.id = drow(<span style="color:#a31515;">&quot;id&quot;</span>)</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; obj.Name = drow(<span style="color:#a31515;">&quot;Name&quot;</span>)</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; obj.Value = drow(<span style="color:#a31515;">&quot;Value&quot;</span>)</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; Que.Enqueue(obj)</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:blue;">Next</span></p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:blue;">Return</span> Que.ToArray</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">End</span> <span style="color:blue;">Function</span></p>
<p style="margin:0;">&nbsp; <span style="color:blue;">End</span> <span style="color:blue;">Class</span></p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;"><span style="color:blue;">End</span> <span style="color:blue;">Namespace</span></p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;"><span style="color:blue;">Namespace</span> vbGuru</p>
<p style="margin:0;">&nbsp; <span style="color:blue;">Public</span> <span style="color:blue;">Class</span> DB</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">Public</span> <span style="color:blue;">Function</span> GetObj() <span style="color:blue;">As</span> DataTable</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:blue;">Dim</span> cn <span style="color:blue;">As</span> System.Data.SqlClient.SqlConnection = <span style="color:blue;">New</span> System.Data.SqlClient.SqlConnection(<span style="color:#a31515;">&quot;CNSTRING&quot;</span>)</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:blue;">Dim</span> cmd <span style="color:blue;">As</span> System.Data.SqlClient.SqlCommand = <span style="color:blue;">New</span> System.Data.SqlClient.SqlCommand(<span style="color:#a31515;">&quot;SELECT * FROM TMP&quot;</span>, cn)</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:blue;">Dim</span> ds <span style="color:blue;">As</span> System.Data.SqlClient.SqlDataAdapter = <span style="color:blue;">New</span> System.Data.SqlClient.SqlDataAdapter(cmd)</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:blue;">Dim</span> dt <span style="color:blue;">As</span> DataTable = <span style="color:blue;">New</span> DataTable</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; ds.Fill(dt)</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:blue;">Return</span> dt</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">End</span> <span style="color:blue;">Function</span></p>
<p style="margin:0;">&nbsp; <span style="color:blue;">End</span> <span style="color:blue;">Class</span></p>
<p style="margin:0;"><span style="color:blue;">End</span> <span style="color:blue;">Namespace</span></p>
</div>
<p>It may seem like a lot of steps just to do a simple function but by separating it all out it makes your code easier to maintain, easier to make a database change, and easily reusable.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbguru.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbguru.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbguru.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbguru.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbguru.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbguru.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbguru.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbguru.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbguru.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbguru.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbguru.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbguru.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbguru.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbguru.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=23&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbguru.wordpress.com/2010/01/01/multi-tiered-architecture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f1b1a10278e9d375918280dd0f7347bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Daryl</media:title>
		</media:content>
	</item>
		<item>
		<title>Advanced SQL Concept: Temp Tables</title>
		<link>http://vbguru.wordpress.com/2009/12/16/advanced-sql-concept-temp-tables/</link>
		<comments>http://vbguru.wordpress.com/2009/12/16/advanced-sql-concept-temp-tables/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 15:00:00 +0000</pubDate>
		<dc:creator>Daryl</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://vbguru.wordpress.com/?p=32</guid>
		<description><![CDATA[Often in an advanced SQL stored procedure you need to create a temporary table in the database to dump data into. There are two methods available to do this. One is using the # symbol and giving it any name, like so: CREATE TABLE #TempTable ( TempID int, TempName varchar(30) ) The problem with this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=32&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Often in an advanced SQL stored procedure you need to create a temporary table in the database to dump data into.  There are two methods available to do this.  One is using the # symbol and giving it any name, like so:</p>
<pre class="brush: sql;">
CREATE TABLE #TempTable (
  TempID int,
  TempName varchar(30)
)
</pre>
<p>The problem with this method is that the temp table stays around in memory until you call drop table #TempTable</p>
<p>I suggest you use a variable to create the table like so:</p>
<pre class="brush: sql;">
DECLARE @TABLE AS TABLE
(
  TempID int,
  TempName varchar(30)
)
</pre>
<p>By doing it this way your table is only scoped within your stored procedure and so it will disappear once your SP stops executing and you don&#8217;t need to worry about dropping it.</p>
<p>Once you&#8217;ve created your table you use it like any other table you just need to remember to keep the @ or # at the beginning of the table name, depending on which method above you used.</p>
<p>Here is one way that you could use it:</p>
<pre class="brush: sql;">

DECLARE @TempTable AS TABLE
(
	idUser bigint,
	UserName varchar(50)
)

INSERT INTO @TempTable
SELECT idUser, UserName from tblUser

DECLARE @USR varchar(50)

SELECT @USR =UserName from @TempTable where idUser = 15
</pre>
<p>I usually use it when you have a super complicated Query and then you need to filter it down and adding your new filter to your SQL statement would drive you insane.</p>
<p>Here is some real code I created using one:</p>
<pre><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-size:small;"><span style="line-height:19px;white-space:normal;"><span style="font-family:Consolas, Monaco, 'Courier New', Courier, monospace;font-size:small;"><span style="line-height:18px;white-space:pre;">
</span></span></span></span></pre>
<pre class="brush: sql;">
DECLARE @TABLE AS TABLE
(
idUser bigint,
Value int,
CurVal int
)

INSERT INTO @TABLE (Value, CurVal, idUser)
select DISTINCT Value, (SELECT UserValue from tblUserDetails where idUserDetailsField = 11 and idUser =(
(SELECT idUser from tblUser where id =
(SELECT DISTINCT Value from tblImportData where Field = 'System ID' and Row = d.Row and idImport = d.idImport))))
As CurVal,
(SELECT idUser from tblUser where id =
(SELECT DISTINCT Value from tblImportData where Field = 'System ID' and Row = d.Row and idImport = d.idImport))
As idUser
from tblImportData as d where Field = '% UserValue' and idImport = @idImport
Order by idUser

SELECT idUser from @TABLE where Value &lt;&gt; CurVal
</pre>
<p>I needed to add that compare, Value &lt;&gt; CurVal, to the sql query, but it boggled my mind so I just created a temp table, maybe a SQL Guru could have done it better.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbguru.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbguru.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbguru.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbguru.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbguru.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbguru.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbguru.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbguru.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbguru.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbguru.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbguru.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbguru.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbguru.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbguru.wordpress.com/32/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=32&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbguru.wordpress.com/2009/12/16/advanced-sql-concept-temp-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f1b1a10278e9d375918280dd0f7347bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Daryl</media:title>
		</media:content>
	</item>
		<item>
		<title>Shutting up the warnings</title>
		<link>http://vbguru.wordpress.com/2009/12/15/shutting-up-the-warnings/</link>
		<comments>http://vbguru.wordpress.com/2009/12/15/shutting-up-the-warnings/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 15:00:00 +0000</pubDate>
		<dc:creator>Daryl</dc:creator>
				<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://vbguru.wordpress.com/2009/12/17/shutting-up-the-warnings</guid>
		<description><![CDATA[Ok ever have some code like this: &#160; Function GetMine(ByVal id As Integer) As ObjMine &#160; &#160; Dim Obj As ObjMine &#160; &#160; If id = 0 Then &#160; &#160; &#160; Obj = New ObjMine(id) &#160; &#160; End If &#160; &#160; Return Obj &#160; End Function Visual studio will warn you: Warning 2 Function &#8216;GetMine&#8217; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=27&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ok ever have some code like this:</p>
<p>
<div style="background:white;color:black;font-family:Courier New;font-size:10pt;">
<div style="margin:0;">&nbsp; <span style="color:blue;">Function</span> GetMine(<span style="color:blue;">ByVal</span> id <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>) <span style="color:blue;">As</span> ObjMine</div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">Dim</span> Obj <span style="color:blue;">As</span> ObjMine</div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">If</span> id = 0 <span style="color:blue;">Then</span></div>
<div style="margin:0;">&nbsp; &nbsp; &nbsp; Obj = <span style="color:blue;">New</span> ObjMine(id)</div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">End</span> <span style="color:blue;">If</span></div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">Return</span> Obj</div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; <span style="color:blue;">End</span> <span style="color:blue;">Function</span></div>
</div>
<p>Visual studio will warn you:</p>
<p>Warning 2 Function &#8216;GetMine&#8217; doesn&#8217;t return a value on all code paths. A null reference exception could occur at run time when the result is used.&#8217;</p>
<p>But your thinking &#8220;But I want it to return nothing if there is no object with that ID, so stop bugging me!&#8221;</p>
<p>Well here is my little trick to fix that:</p>
<div style="background:white;color:black;font-family:Courier New;font-size:10pt;">
<div style="margin:0;">&nbsp; <span style="color:blue;">Function</span> GetMine(<span style="color:blue;">ByVal</span> id <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>) <span style="color:blue;">As</span> ObjMine</div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">Dim</span> Obj <span style="color:blue;">As</span> ObjMine = <span style="color:blue;">Nothing</span></div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">If</span> id = 0 <span style="color:blue;">Then</span></div>
<div style="margin:0;">&nbsp; &nbsp; &nbsp; Obj = <span style="color:blue;">New</span> ObjMine(id)</div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">End</span> <span style="color:blue;">If</span></div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">Return</span> Obj</div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; <span style="color:blue;">End</span> <span style="color:blue;">Function</span></div>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbguru.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbguru.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbguru.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbguru.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbguru.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbguru.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbguru.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbguru.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbguru.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbguru.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbguru.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbguru.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbguru.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbguru.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=27&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbguru.wordpress.com/2009/12/15/shutting-up-the-warnings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f1b1a10278e9d375918280dd0f7347bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Daryl</media:title>
		</media:content>
	</item>
		<item>
		<title>If Not obj is nothing</title>
		<link>http://vbguru.wordpress.com/2009/12/14/if-not-obj-is-nothing/</link>
		<comments>http://vbguru.wordpress.com/2009/12/14/if-not-obj-is-nothing/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 15:00:00 +0000</pubDate>
		<dc:creator>Daryl</dc:creator>
				<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://vbguru.wordpress.com/2009/12/16/if-not-obj-is-nothing</guid>
		<description><![CDATA[I happen to love &#8220;If Not&#8221; it even got me in trouble at work. I don&#8217;t think it was available in VB6 but I might have just not known about it. Back in my VB6 Days I would often write an if statement like so: &#160; &#160; If obj Is Nothing Then &#160; &#160; &#160; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=26&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I happen to love &#8220;If Not&#8221; it even got me in trouble at work.  I don&#8217;t think it was available in VB6 but I might have just not known about it.  Back in my VB6 Days I would often write an if statement like so:</p>
<div style="background:white;color:black;font-family:Courier New;font-size:10pt;">
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">If</span> obj <span style="color:blue;">Is</span> <span style="color:blue;">Nothing</span> <span style="color:blue;">Then</span></div>
<div style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:green;">&#8216;Do Nothing</span></div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">Else</span></div>
<div style="margin:0;">&nbsp; &nbsp; &nbsp; Obj = <span style="color:blue;">New</span> <span style="color:blue;">Object</span></div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">End</span> <span style="color:blue;">If</span></div>
</div>
<p>This solves the issue of there not being an &#8216;isnot&#8217; operator, but it looks bad.  Well In .NET you can use &#8220;If Not&#8221; to solve this:</p>
<div style="background:white;color:black;font-family:Courier New;font-size:10pt;">
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">If</span> <span style="color:blue;">Not</span> obj <span style="color:blue;">Is</span> <span style="color:blue;">Nothing</span> <span style="color:blue;">Then</span></div>
<div style="margin:0;">&nbsp; &nbsp; &nbsp; obj = <span style="color:blue;">New</span> <span style="color:blue;">Object</span></div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">End</span> <span style="color:blue;">If</span></div>
</div>
<p>I got into trouble at work when I used it this way:</p>
<div style="background:white;color:black;font-family:Courier New;font-size:10pt;">
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">If</span> <span style="color:blue;">Not</span> i = 1 <span style="color:blue;">Then</span></div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">End</span> <span style="color:blue;">If</span></div>
</div>
<p>My code reviewer made me rewrite it to:</p>
<div style="background:white;color:black;font-family:Courier New;font-size:10pt;">
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">If</span> i &lt;&gt; 1 <span style="color:blue;">Then</span></div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">End</span> <span style="color:blue;">If</span></div>
</div>
<p>I think it was a fine line of code but I may have just been addicted to If Not, but I admit it is a little confusing.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbguru.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbguru.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbguru.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbguru.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbguru.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbguru.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbguru.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbguru.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbguru.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbguru.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbguru.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbguru.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbguru.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbguru.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=26&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbguru.wordpress.com/2009/12/14/if-not-obj-is-nothing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f1b1a10278e9d375918280dd0f7347bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Daryl</media:title>
		</media:content>
	</item>
		<item>
		<title>Sending An Email using SSL &amp; Comcast</title>
		<link>http://vbguru.wordpress.com/2009/12/11/sending-an-email-using-ssl-comcast/</link>
		<comments>http://vbguru.wordpress.com/2009/12/11/sending-an-email-using-ssl-comcast/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 15:00:13 +0000</pubDate>
		<dc:creator>Daryl</dc:creator>
				<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://vbguru.wordpress.com/?p=97</guid>
		<description><![CDATA[Here is something I just figured out, it took me a while because I was trying to use the some older settings that I had found before. Port 587 is the one you want to use with Comcast &#38; .net. This code works with my comcast account. Private Sub SendEmail() Dim smtp As System.Net.Mail.SmtpClient smtp [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=97&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is something I just figured out, it took me a while because I was trying to use the some older settings that I had found before.  Port 587 is the one you want to use with Comcast &amp; .net.</p>
<p>This code works with my comcast account.</p>
<pre class="brush: vb;">
  Private Sub SendEmail()

    Dim smtp As System.Net.Mail.SmtpClient
    smtp = New System.Net.Mail.SmtpClient(&quot;smtp.comcast.net&quot;, 587)
    smtp.UseDefaultCredentials = False
    'NOTE: USER_NAME does not include the @comcast.net part
    smtp.Credentials = New System.Net.NetworkCredential(&quot;USER_NAME&quot;, &quot;PASSWORD&quot;)
    smtp.EnableSsl = True
    smtp.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network

    smtp.Send(&quot;USER_NAME@COMCAST.NET&quot;, &quot;USER@USER.COM&quot;, &quot;TEST SUBJECT&quot;, &quot;TEST MESSAGE&quot;)

  End Sub
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbguru.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbguru.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbguru.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbguru.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbguru.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbguru.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbguru.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbguru.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbguru.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbguru.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbguru.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbguru.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbguru.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbguru.wordpress.com/97/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=97&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbguru.wordpress.com/2009/12/11/sending-an-email-using-ssl-comcast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f1b1a10278e9d375918280dd0f7347bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Daryl</media:title>
		</media:content>
	</item>
		<item>
		<title>Stupid LINQ Error</title>
		<link>http://vbguru.wordpress.com/2009/12/10/stupid-linq-error/</link>
		<comments>http://vbguru.wordpress.com/2009/12/10/stupid-linq-error/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 15:00:00 +0000</pubDate>
		<dc:creator>Daryl</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://vbguru.wordpress.com/2009/12/10/stupid-linq-error</guid>
		<description><![CDATA[Ok in the end this was my fault, I&#8217;m not sure how I messed it up, but I just had to pull my hair out trying to figure out why I was getting this error using LINQ. System.NotSupportedException: Method &#8216;System.Object CompareObjectEqual(System.Object, System.Object, Boolean)&#8217; has no supported translation to SQL. &#160; Private Function TEMP_LINQ(ByVal SessionID, ByVal [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=22&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ok in the end this was my fault, I&#8217;m not sure how I messed it up, but I just had to pull my hair out trying to figure out why I was getting this error using LINQ.</p>
<p>System.NotSupportedException: Method &#8216;System.Object CompareObjectEqual(System.Object, System.Object, Boolean)&#8217; has no supported translation to SQL.</p>
<div style="background:white;color:black;font-family:Courier New;font-size:10pt;">
<div style="margin:0;">&nbsp; <span style="color:blue;">Private</span> <span style="color:blue;">Function</span> TEMP_LINQ(<span style="color:blue;">ByVal</span> SessionID, <span style="color:blue;">ByVal</span> AdvisorID, <span style="color:blue;">ByVal</span> StudentID) <span style="color:blue;">As</span> <span style="color:blue;">Boolean</span></div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">Dim</span> db <span style="color:blue;">As</span> MyDB = <span style="color:blue;">New</span> MyDB(Conn.ToString)</div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">Dim</span> Query = (<span style="color:blue;">From</span> t <span style="color:blue;">In</span> db.tblUsers <span style="color:blue;">Where</span> t.idAdvisor = AdvisorID <span style="color:blue;">And</span> t.idStudent = StudentID <span style="color:blue;">And</span> t.idSession = SessionID).FirstOrDefault</div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">If</span> Query <span style="color:blue;">Is</span> <span style="color:blue;">Nothing</span> <span style="color:blue;">Then</span> <span style="color:blue;">Return</span> <span style="color:blue;">False</span></div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">Return</span> <span style="color:blue;">True</span></div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; <span style="color:blue;">End</span> <span style="color:blue;">Function</span></div>
</div>
<p>The problem was that for some reason I deleted all my types in my function setting this fixed the problem. This is not&nbsp;something&nbsp; that I ever do, I just messed up a copy and paste process where I renamed the variables, in the process of which I&nbsp;accidentally&nbsp;forgot to give all my variables types, and this makes LINQ puke.</p>
<div style="background:white;color:black;font-family:Courier New;font-size:10pt;">
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; <span style="color:blue;">Private</span> <span style="color:blue;">Function</span> TEMP_LINQ(<span style="color:blue;">ByVal</span> SessionID <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> AdvisorID <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> StudentID <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>) <span style="color:blue;">As</span> <span style="color:blue;">Boolean</span></div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">Dim</span> db <span style="color:blue;">As</span> MyDB = <span style="color:blue;">New</span> MyDB (Conn.ToString)</div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">Dim</span> Query = (<span style="color:blue;">From</span> t <span style="color:blue;">In</span> db.tblUsers <span style="color:blue;">Where</span> t.idAdvisor = AdvisorID <span style="color:blue;">And</span> t.idStudent = StudentID <span style="color:blue;">And</span> t.idSession = SessionID).FirstOrDefault</div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">If</span> Query <span style="color:blue;">Is</span> <span style="color:blue;">Nothing</span> <span style="color:blue;">Then</span> <span style="color:blue;">Return</span> <span style="color:blue;">False</span></div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; &nbsp; <span style="color:blue;">Return</span> <span style="color:blue;">True</span></div>
<div style="margin:0;"></div>
<div style="margin:0;">&nbsp; <span style="color:blue;">End</span> <span style="color:blue;">Function</span></div>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbguru.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbguru.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbguru.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbguru.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbguru.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbguru.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbguru.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbguru.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbguru.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbguru.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbguru.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbguru.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbguru.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbguru.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbguru.wordpress.com&amp;blog=10840974&amp;post=22&amp;subd=vbguru&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbguru.wordpress.com/2009/12/10/stupid-linq-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f1b1a10278e9d375918280dd0f7347bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Daryl</media:title>
		</media:content>
	</item>
	</channel>
</rss>
