<?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; Databases</title>
	<atom:link href="http://www.webdevelopmentbygeorge.com/tag/databases/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>CFAjaxProxy Problems or RTFM</title>
		<link>http://www.webdevelopmentbygeorge.com/2010/05/17/cfajaxproxy/</link>
		<comments>http://www.webdevelopmentbygeorge.com/2010/05/17/cfajaxproxy/#comments</comments>
		<pubDate>Mon, 17 May 2010 19:24:20 +0000</pubDate>
		<dc:creator>George</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.webdevelopmentbygeorge.com/?p=211</guid>
		<description><![CDATA[So recently I&#8217;d been doing a cfselect box using bind to create my desired linked drop down.  The problem I was having was that I wanted to do a zebra stripe on the select after it had been loaded.  I could not find a way to attach the bind event to anything else so I [...]]]></description>
			<content:encoded><![CDATA[<p>So recently I&#8217;d been doing a cfselect box using bind to create my desired linked drop down.  The problem I was having was that I wanted to do a zebra stripe on the select after it had been loaded.  I could not find a way to attach the bind event to anything else so I couldn&#8217;t call a function after the bind had actually completed.  The way I wanted to solve this was to use a setTimeout on the coloring process.  The problem I was having was that my serializedJSON output I was using was no longer working.  It turns out &#8211; if you read the documentation &#8211; that using cfajaxproxy to pull in a CFC automatically serializes your output.  So if you&#8217;re returning a result of String with a serializeJSON(myQuery) you will end up with the data being DOUBLE SERIALIZED! Oh what a headache that was.  The proper way to do this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="js" style="font-family:monospace;">   &lt;cfajaxproxy cfc=&quot;myData&quot; jsclassname=&quot;myDataClass&quot; /&gt;
&nbsp;
   &lt;script&gt;
	getData = function(){
		var o = new myDataClass();
		var dataset = o.getData($('toggleField').checked);
		return dataset;
	}
   &lt;/script&gt;</pre></td></tr></table></div>

<p>Is to have your CFC do 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
13
14
</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;">cfcomponent</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;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;getData&quot;</span> <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;remote&quot;</span> returntype<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;query&quot;</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;">cfargument</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;myToggle&quot;</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;string&quot;</span> <span style="color: #0000FF;">required</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;yes&quot;</span> <span style="color: #0000FF;">default</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;false&quot;</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> <span style="color: #000000; font-weight: bold;">var</span> qryData <span style="color: #0000FF;">=</span> <span style="color: #FF0000;">0</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;qryData &quot;</span> <span style="color: #0000FF;">datasource</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;DATAS&quot;</span><span style="color: #0000FF;">&gt;</span></span>	
			SELECT *
                           FROM tableData
                <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;">cfreturn</span> qryData<span style="color: #0000FF;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</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;">cfcomponent</span><span style="color: #0000FF;">&gt;</span></span></pre></td></tr></table></div>

<p>Rather than serializing it yourself first.  If you&#8217;re binding with a method of cfc: then you don&#8217;t need to do this, instead you need to change it to return text and use the SerializeJSON on your qryData query.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdevelopmentbygeorge.com/2010/05/17/cfajaxproxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>
