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

<channel>
	<title>BKeeney Briefs &#187; recordset</title>
	<atom:link href="http://www.bkeeneybriefs.com/tag/recordset/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bkeeneybriefs.com</link>
	<description>Software Development Using REALbasic</description>
	<lastBuildDate>Fri, 03 Sep 2010 22:24:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Why Is My Recordset Nil?</title>
		<link>http://www.bkeeneybriefs.com/2009/05/why-is-my-recordset-nil/</link>
		<comments>http://www.bkeeneybriefs.com/2009/05/why-is-my-recordset-nil/#comments</comments>
		<pubDate>Wed, 27 May 2009 20:15:02 +0000</pubDate>
		<dc:creator>Bob Keeney</dc:creator>
				<category><![CDATA[REALbasic]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[recordset]]></category>

		<guid isPermaLink="false">http://www.bkeeneybriefs.com/?p=25</guid>
		<description><![CDATA[This one comes up on the RB Forums a lot.  The post generally goes something like this:  &#8220;I have a database and everything works fine until here &#60;insert code snippet&#62; and I get a Nil Object Exception because rs is nil.&#8221; If everything else is working fine then it must be the recordset.  If you&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p>This one comes up on the RB Forums a lot.  The post generally goes something like this:  &#8220;I have a database and everything works fine until here &lt;insert code snippet&gt; and I get a Nil Object Exception because rs is nil.&#8221;</p>
<p>If everything else is working fine then it must be the recordset.  If you&#8217;re not checking the database for an error you&#8217;ll never know!  The db.error property tells you that you had an error and the db.errormessage property does a pretty good job of telling you what the error is.</p>
<p style="padding-left: 30px;">dim rs as recordset<br />
rs = db.SQLSelect(&#8220;SELECT * FROM sometable WHERE somefield=avalue&#8221;)<br />
if db.error then<br />
msgbox &#8220;Error!&#8221; + db.ErrorMessage<br />
return<br />
end</p>
<p style="padding-left: 30px;">//do something with the recordset here.</p>
<p>I find this happens a lot with developers that came from Visual Basic 6 where database errors throw an exception.  REALbasic doesn&#8217;t work the same way.  Get over it and start checking for database errors.</p>
<p>If you want to capture database errors you can do something like what we&#8217;ve done:</p>
<p style="padding-left: 30px;">if gDB.Error then Raise new BK_Debug.BK_DatabaseException(gDB.ErrorMessage, s)</p>
<p>Where BK_DatabaseException is a RuntimeException subclass defined like this:</p>
<p style="padding-left: 30px;">Sub Constructor(sMessage as string, sSQL as string)<br />
If sMessage &lt;&gt; &#8220;&#8221; Then<br />
Me.Message = sMessage<br />
End If</p>
<p style="padding-left: 30px;">If sSQL &lt;&gt; &#8220;&#8221; Then<br />
Me.Message = Me.Message + EndOfLine +  EndOfLine + sSQL<br />
End<br />
End Sub</p>
<p>This can be useful if you have automated error handling and can receive this information.  Of course, if you&#8217;re creating a runtime exception you had better be handling them in the app.unhandledexception event otherwise your app will shutdown and you&#8217;ll have pissed off users.</p>
            <script type="text/javascript">  linkscolor = "000000";  highlightscolor = "888888";  backgroundcolor = "FFFFFF";  channel = "none";   </script><script type="text/javascript" src="http://www.addmarx.com/dynamicbookmark_compressed.php"></script><span><a onClick="clickDynamic1(this); return false;" href="http://www.addmarx.com"><img style="padding:0px; margin:0px" src="http://www.bkeeneybriefs.com/wp-content/plugins/addmarx/sharebookmarx.png" border="0"></a></span><span style="position:absolute; z-index:1000001; margin-top:24px; margin-left:-127px; visibility:hidden;"><iframe id="addmarx_empty" scrolling="no" frameborder="0"></iframe></span><p class="addmarx_spacer"></p><!-- Please place the above code into your site where you want to have a bookmark/share/publicize link. Please do not change any of the code aside from the link text or image, or else the code may not work properly.  -->                  ]]></content:encoded>
			<wfw:commentRss>http://www.bkeeneybriefs.com/2009/05/why-is-my-recordset-nil/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
