<?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>Web Development By George &#187; Access</title>
	<atom:link href="http://www.webdevelopmentbygeorge.com/tag/access/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webdevelopmentbygeorge.com</link>
	<description>ColdFusion, JavaScript and more!</description>
	<lastBuildDate>Sat, 21 Aug 2010 00:16:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Microsoft Access &#8211; Random Identity Seeds and @@Identity</title>
		<link>http://www.webdevelopmentbygeorge.com/2010/02/19/microsoft-access-random-identity-seeds-and-identity/</link>
		<comments>http://www.webdevelopmentbygeorge.com/2010/02/19/microsoft-access-random-identity-seeds-and-identity/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 20:49:08 +0000</pubDate>
		<dc:creator>George</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Access]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbygeorge.com/?p=186</guid>
		<description><![CDATA[So I discovered a few things with Microsoft Access recently.  It&#8217;s not my database of choice, but it&#8217;s very easy in my current work environment to use it effectively &#8211; and effectiveness is always the key.  So we have been discussing more and better ways to implement security.  One of the ways [...]]]></description>
			<content:encoded><![CDATA[<p>So I discovered a few things with Microsoft Access recently.  It&#8217;s not my database of choice, but it&#8217;s very easy in my current work environment to use it effectively &#8211; and effectiveness is always the key.  So we have been discussing more and better ways to implement security.  One of the ways to do this is to change how the ID for a record is created.  Access provides a way to use GUIDs for the AutoNumber column of your choice, but they&#8217;re very cumbersome &#8211; especially if you&#8217;re going to be passing them around in a secure app environment as a URL string.  I know, URL Strings aren&#8217;t the best, but they&#8217;re fast.  That references back to the same thing as effectiveness in my book!  Well I didn&#8217;t like the way they looked so I changed back to a Number format and started getting very odd results for the AutoNumber.  Very long integers as well as negatives and they were no longer sequential.  That&#8217;ll teach me not to click on the &#8220;New Values&#8221; option of my AutoNumber fields.  There&#8217;s an option there to change them to &#8220;Random&#8221; from &#8220;Increment&#8221;.  This will help by providing a minor bit of security where users before might have been able to change the URL ID and change what record they were looking at.</p>
<p>The next problem this created for me was in the way I normally had been grabbing the newly created records in my Access tables.  I guess it&#8217;s pretty standard for most people to do something along these lines when creating and inserting values into your access tables:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfquery</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;test1&quot;</span> <span style="color: #0000FF;">datasource</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;source1&quot;</span><span style="color: #0000FF;">&gt;</span></span>
     INSERT INTO Table (datacol)
     VALUES (&quot;datapiece&quot;);
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfquery</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfquery</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;getID&quot;</span> <span style="color: #0000FF;">datasource</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;source1&quot;</span><span style="color: #0000FF;">&gt;</span></span>
    SELECT MAX(ID) as MaxID FROM Table
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfquery</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> myID <span style="color: #0000FF;">=</span> getID.MaxID <span style="color: #0000FF;">/&gt;</span></span></pre></td></tr></table></div>

<p>Well this didn&#8217;t work anymore with the Random seed for the AutoNumber.  The max was no longer the last one inserted.  It led to quite a bit of hair pulling on my part &#8211; and that&#8217;s an accomplishment when you&#8217;re bald.  So I had heard from a co-worker that @@Identity did in fact work in Access.  I hadn&#8217;t spent much time looking into it &#8211; being as I had a solution that worked (Max(id)) and I prefer to work in SQL Server or MySQL.  But now I was presented with a need to figure it out.  A few minutes of Googling led me to <a href="http://cfmxplus.blogspot.com/2002/08/oh-my-select-identity-works-in-access.html">this article by Charlie Arehart</a> from 2002(!)  I was a little surprised to see it had been working for this long.  So now I do my access inserts like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cftransaction</span><span style="color: #0000FF;">&gt;</span></span>
      <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfquery</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;test1&quot;</span> <span style="color: #0000FF;">datasource</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;source1&quot;</span><span style="color: #0000FF;">&gt;</span></span>
             INSERT INTO Table (datacol)
             VALUES (&quot;datapiece&quot;);
      <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfquery</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
      <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfquery</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;getID&quot;</span> <span style="color: #0000FF;">datasource</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;source1&quot;</span><span style="color: #0000FF;">&gt;</span></span>
             SELECT @@IDENTITY as MaxID;
      <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfquery</span><span style="color: #0000FF;">&gt;</span></span>	
&nbsp;
      <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> myID <span style="color: #0000FF;">=</span> getID.MaxID <span style="color: #0000FF;">/&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cftransaction</span><span style="color: #0000FF;">&gt;</span></span></pre></td></tr></table></div>

<p>And everything works out just fine.  The keys are the CFTransaction tag and using two separate CFQuery tags.  Now to go revamp a whole section of code to use this little tidbit!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbygeorge.com/2010/02/19/microsoft-access-random-identity-seeds-and-identity/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Microsoft Access Truncating Memo Fields</title>
		<link>http://www.webdevelopmentbygeorge.com/2009/05/14/microsoft-access-truncating-memo-fields/</link>
		<comments>http://www.webdevelopmentbygeorge.com/2009/05/14/microsoft-access-truncating-memo-fields/#comments</comments>
		<pubDate>Thu, 14 May 2009 17:27:59 +0000</pubDate>
		<dc:creator>George</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Access]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbygeorge.com/?p=69</guid>
		<description><![CDATA[Okay &#8211; so today one of the previous sites I had worked on was having difficulty because text was being truncated on a display section.  I looked in the database and sure enough all of the data was there, but when I ran the query that was on the page, I noticed that it was [...]]]></description>
			<content:encoded><![CDATA[<p>Okay &#8211; so today one of the previous sites I had worked on was having difficulty because text was being truncated on a display section.  I looked in the database and sure enough all of the data was there, but when I ran the query that was on the page, I noticed that it was cutting off the data at about string length, 255 characters.  After some quick digging around, I came across this website:  <a href="http://allenbrowne.com/ser-63.html">http://allenbrowne.com/ser-63.html</a>.  Well wouldn&#8217;t you know it.  I had a DISTINCT operator in my query, which was causing the field to be truncated down to string length.  Now that problem is solved, on to the next!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbygeorge.com/2009/05/14/microsoft-access-truncating-memo-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
