<?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>Geospecialling &#187; Oracle</title>
	<atom:link href="http://www.geospecialling.com/index.php/tag/oracle/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geospecialling.com</link>
	<description>Being a (G)IS Developer...</description>
	<lastBuildDate>Thu, 26 Jan 2012 04:11:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>OracleCommand and parameterized update statements</title>
		<link>http://www.geospecialling.com/index.php/2011/11/oraclecommand-and-parameterized-update-statements/</link>
		<comments>http://www.geospecialling.com/index.php/2011/11/oraclecommand-and-parameterized-update-statements/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 22:07:53 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[RADE]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[ODP.NET]]></category>
		<category><![CDATA[Parameterized Queries]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2011/11/oraclecommand-and-parameterized-update-statements/</guid>
		<description><![CDATA[This week I encountered an irritating situation with Oracle while working on code in the RADE application logic.&#160; In a nutshell I am building dynamically created parameterized insert and update statements based on the RADE metadata and the values entered by the user.&#160; The first call InsertNewRecord works perfectly.&#160; The next call UpdateExistingRecord however was [...]]]></description>
			<content:encoded><![CDATA[<p>This week I encountered an irritating situation with Oracle while working on code in the <a title="RADE" href="http://www.geospecialling.com/index.php/2008/06/rade-build-custom-web-applications-without-writing-custom-code/" rel="tag" target="_blank">RADE</a> application logic.&#160; In a nutshell I am building dynamically created parameterized insert and update statements based on the RADE metadata and the values entered by the user.&#160; The first call InsertNewRecord works perfectly.&#160; The next call UpdateExistingRecord however was not.&#160; The parameterized SQL was being created.&#160; The parameters were being created and assigned to the <a title="DbCommand" href="http://msdn.microsoft.com/en-us/library/system.data.common.dbcommand.aspx" rel="tag" target="_blank">DbCommand</a>.&#160; The ExecuteNonQuery() call was executing without returning an error.&#160; Oracle just would not update.&#160;&#160; Even more frustrating – this “just worked” in SQL server.</p>
<h2>What were the differences?</h2>
<p>The basic logic for insert was this (parts omitted because you probably just don’t care):</p>
<ol>
<li>Get table metadata </li>
<li>Loop through fields in table </li>
<li>for each field retrieve the value from the UI </li>
<li>Add field to parameterized SQL statement with placeholder </li>
<li>Create new parameter with appropriate name and value.&#160;&#160; Add parameter to collection </li>
<li>Loop through parameters in the collection and add to the DbCommand </li>
<li>Finally execute the parameterized SQL statement </li>
</ol>
<p>As I mentioned this worked great.&#160; Fields were inserted and there was much rejoicing.</p>
<p>The logic for an update was similar but there was one big difference:</p>
<ol>
<li>Get Table </li>
<li>Loop through fields in table </li>
<li>for each field retrieve the value from the UI </li>
<li>If the field is a key add the placeholder to the where condition, otherwise add the field name and value to the update fields part of the SQL </li>
<li>Create new parameter with appropriate name and value.&#160; Add parameter to collection </li>
<li>Loop through parameters in the collection and add to the DbCommand </li>
<li>Finally execute the parameterized SQL statement. </li>
</ol>
<p>The branch in step 4 and the if statement ended up causing the problem.</p>
<h2>The Problem</h2>
<p><a title="OracleCommand" href="http://msdn.microsoft.com/en-us/library/system.data.oracleclient.oraclecommand(v=VS.100).aspx" rel="tag" target="_blank">OracleCommand</a> defaults to “bind by order” – making the order in which the parameters exist in the SQL statement match the order in which the parameters are added to the OracleCommand. This was happening during the insert because of the structure of an insert statement being so linear. However in the update statement I was building the SQL in a more dynamic way. I was maintaining a list field=value conditions and a separate where condition. In the ended up merging them :</p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> String parameterizedSQL = <span style="color: #006080">&quot;UPDATE &quot;</span> + table.Name + <span style="color: #006080">&quot; SET &quot;</span> + updateStatement + <span style="color: #006080">&quot; WHERE &quot;</span> + whereStatement;</pre>
</p></div>
</div>
<p>So unless my key field( s) all lined up at the end of the table metadata definitions,&#160; appending that where condition at the end my parameter order got all out of whack in the DbCommand.&#160; So my where condition was actually being set to the wrong value – which could have resulted in the wrong records being updated. Nasty.&#160;&#160; Fortunately this can be resolved.</p>
<h2>The Fix – BindByName=true</h2>
<p>To correct this I had to set the Oracle specific BindByName property to true.&#160; (btw this being the default behavior is just silly.&#160; All the other big data providers default to bind by name and Oracle should too.&#160; That’s a rant for another day though.)&#160;&#160; My initial solution was to check if the command is an OracleCommand and if found do a little casting to set the BindByName property then recast it back to DbCommand before executing the query.&#160; Constructive feedback is always welcome!</p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #008000">/// &lt;summary&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> <span style="color: #008000">/// Execute the parameterized query</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span> <span style="color: #008000">/// &lt;/summary&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span> <span style="color: #008000">/// &lt;param name=&quot;conn&quot;&gt;open and active DbConnection&lt;/param&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span> <span style="color: #008000">/// &lt;param name=&quot;trans&quot;&gt;Active DbTransaction&lt;/param&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span> <span style="color: #008000">/// &lt;param name=&quot;parameterizedSQL&quot;&gt;the parameterized SQL&lt;/param&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   7:</span> <span style="color: #008000">/// &lt;param name=&quot;paramList&quot;&gt;List of OledDbParameter&lt;/param&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   8:</span> <span style="color: #008000">/// &lt;returns&gt;DataTable containing the results&lt;/returns&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   9:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> RunParameterizedInsertUpdate(DbConnection conn, DbTransaction trans, String parameterizedSQL, List&lt;DbParameter&gt; paramList)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  10:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  11:</span>     <span style="color: #008000">//create the db command and set the parameterized SQL as a property</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  12:</span>     DbCommand command = conn.CreateCommand();</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  13:</span>     <span style="color: #0000ff">if</span>(trans != <span style="color: #0000ff">null</span>)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  14:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  15:</span>         command.Transaction = trans;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  16:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  17:</span>     <span style="color: #008000">//hack attack!  By default, Oracle requires its parameters to be placed into the command</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  18:</span>     <span style="color: #008000">//in the order the parameters appear in the parameterized SQL.  Little hackery here</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  19:</span>     <span style="color: #008000">//to set the Oracle Command to bind by name</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  20:</span>     <span style="color: #0000ff">if</span> (command <span style="color: #0000ff">is</span> Oracle.DataAccess.Client.OracleCommand)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  21:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  22:</span>         OracleCommand oraCmd = (OracleCommand) command;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  23:</span>         oraCmd.BindByName = <span style="color: #0000ff">true</span>;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  24:</span>         command = oraCmd;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  25:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  26:</span>     command.CommandText = parameterizedSQL;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  27:</span>     command.CommandType = CommandType.Text;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  28:</span>&#160; </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  29:</span>     <span style="color: #008000">//loop through the params and add them to the command</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  30:</span>     <span style="color: #0000ff">foreach</span> (DbParameter parameter <span style="color: #0000ff">in</span> paramList)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  31:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  32:</span>         command.Parameters.Add(parameter);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  33:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  34:</span>     <span style="color: #0000ff">try</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  35:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  36:</span>         command.Prepare();</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  37:</span>         command.ExecuteNonQuery();</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  38:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  39:</span>     <span style="color: #0000ff">catch</span> (Exception ex)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  40:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  41:</span>         command.Dispose();</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  42:</span>         <span style="color: #0000ff">throw</span>;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  43:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  44:</span> }</pre>
</p></div>
</div>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:65e08d4f-940e-4b86-baf5-ae193e7dbe34" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Oracle.+ODP.NET" rel="tag">Oracle. ODP.NET</a>,<a href="http://technorati.com/tags/c%23" rel="tag">c#</a>,<a href="http://technorati.com/tags/parameterized+query" rel="tag">parameterized query</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2011/11/oraclecommand-and-parameterized-update-statements/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing AutoCAD Map 3D 2011 x86 on Vista x64</title>
		<link>http://www.geospecialling.com/index.php/2011/01/installing-autocad-map-3d-2011-x86-on-vista-x64/</link>
		<comments>http://www.geospecialling.com/index.php/2011/01/installing-autocad-map-3d-2011-x86-on-vista-x64/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 05:02:00 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[AutoCAD]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[x64]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2011/01/installing-autocad-map-3d-2011-x86-on-vista-x64/</guid>
		<description><![CDATA[Long ago I gave up trying to get both the 64 and 32 bit Oracle clients working on Vista x64.&#160; I have for now adopted the approach that if it talks to Oracle – it needs to be 32 bit.&#160; Even my development projects are set to x86 only to ensure only the 32 bit [...]]]></description>
			<content:encoded><![CDATA[<p>Long ago I gave up trying to get both the <a title="Oracle x86 x64 hell" href="http://www.geospecialling.com/index.php/2009/05/finally-an-oracle-x64-client-that-works-on-vista-aka-getting-map-2010-x64-running-with-oracle/" rel="tag" target="_blank">64 and 32 bit Oracle clients working on Vista x64</a>.&#160; I have for now adopted the approach that if it talks to Oracle – it needs to be 32 bit.&#160; Even my development projects are set to x86 only to ensure only the 32 bit Oracle client is loaded on my development machine.&#160; </p>
<p>I needed to install <a title="AutoCAD Map 3D 2011" href="http://www.google.com/url?sa=t&amp;source=web&amp;cd=1&amp;ved=0CBYQFjAA&amp;url=http%3A%2F%2Fusa.autodesk.com%2Fadsk%2Fservlet%2Fpc%2Findex%3Fid%3D13818317%26siteID%3D123112&amp;rct=j&amp;q=autocad%20map%202011&amp;ei=DDJHTYufDMzegQfLrJTNAQ&amp;usg=AFQjCNGL_t2Qy5bPlwRpNPkSKmQ7-NgFwA&amp;cad=rja" rel="tag" target="_blank">AutoCAD Map 3D 2011</a>&#160; to debug some <a title="ObjectARX" href="http://www.google.com/url?sa=t&amp;source=web&amp;cd=1&amp;ved=0CBsQFjAA&amp;url=http%3A%2F%2Fusa.autodesk.com%2Fadsk%2Fservlet%2Findex%3Fid%3D773204%26siteID%3D123112&amp;rct=j&amp;q=objectARX&amp;ei=5TFHTdCIHcXOgAep_NzIAQ&amp;usg=AFQjCNGH82-jEJQxFtDrtrkZvck4kPXd8g&amp;cad=rja" rel="tag" target="_blank">ObjectARX</a> code I’ve been working on so I downloaded the 32 bit installer and fired it up only to be informed that my platform was unsupported and I would need to install the 64 bit version.&#160; grrrr.</p>
<p>Google had very little to say on the topic.&#160; More junk about hacking MSI files with Orca.&#160; I took a look at setup.ini and there were far too many references to x64 – I don’t have time for this…Finally I came across the <a title="Longbow Software Converter" href="http://www.longbowsoftware.com/" rel="tag" target="_blank">Longbow Software Converter</a>.&#160; The product claims to modify your setups to allow the 32 bit installers to work on x64 operating systems, 40$.&#160; I couldn’t find any reviews or testimonials so I figured I’d give it a shot…</p>
<p>So here is your first testimonial Longbow Software =)</p>
<p>This actually worked great.&#160; Bought the convert, installed it to a virtual machine.&#160;&#160; The interface is dead simple – paste or browse to the location of the AutoCAD installation files and press Convert.&#160; Keep in mind if you’re running from a DVD you’ll need to copy the contents of the DVD to your PC or a network share so the files can be edited.&#160; I pointed the converter to an install on a network share.&#160; It chugged away for about a minute (keeping in mind this was on an underpowered VM).&#160; Within a matter of minutes I had AutoCAD Map 3D 2011 installing on my Vista x64 box with no problems.&#160; Ran AutoCAD and it seems to fire up no problem.&#160; </p>
<p>Bear in mind – for AutoCAD to work with anything Oracle – you need to have the 32 bit Oracle client running on your machine.</p>
<p>40$ well spent IMO.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2011/01/installing-autocad-map-3d-2011-x86-on-vista-x64/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NHibernate 2.1 throws System.InvalidCastException on Oracle 10g R1 client</title>
		<link>http://www.geospecialling.com/index.php/2010/04/nhibernate-2-1-throws-system-invalidcastexception-on-oracle-10g-r1-client/</link>
		<comments>http://www.geospecialling.com/index.php/2010/04/nhibernate-2-1-throws-system-invalidcastexception-on-oracle-10g-r1-client/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 21:52:00 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[nHibernate]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2010/04/nhibernate-2-1-throws-system-invalidcastexception-on-oracle-10g-r1-client/</guid>
		<description><![CDATA[When deploying an early build of an up and coming product on a customers machine I came across the following error: System.InvalidCastException: Unable to cast object of type &#8216;Oracle.DataAccess.Client.OracleConnection&#8217; to type &#8216;System.Data.Common.DbConnection&#8217; This was one of those awesome “doesn’t happen on any of my machine” errors.&#160; After some mucking around we determined that the client [...]]]></description>
			<content:encoded><![CDATA[<p>When deploying an early build of an up and coming product on a customers machine I came across the following error:</p>
<p><em>System.InvalidCastException: Unable to cast object of type &#8216;Oracle.DataAccess.Client.OracleConnection&#8217; to type &#8216;System.Data.Common.DbConnection&#8217; </em></p>
<p>This was one of those awesome “doesn’t happen on any of my machine” errors.&#160; After some mucking around we determined that the client machine was using the Oracle 10g&#160; R1 client.&#160; The machines and VMs here we used for testing were all running either 11g, or 10g R2.&#160; Doh!</p>
<p>The simple resolution to this was to modify the NHhibernate config and add the following property:</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">property</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;hbm2ddl.keywords&quot;</span><span style="color: #0000ff">&gt;</span>none<span style="color: #0000ff">&lt;/</span><span style="color: #800000">property</span><span style="color: #0000ff">&gt;</span></pre>
</p></div>
</div>
<p>Depending on your underlying databases and mappings this could cause problems with your code project.&#160; Hopefully you’re not using reserved words, or bad Oracle syntax =).</p>
<p>Under the hood, the problem seems to be that the Oracle10gDialect does not provide an implementation of IDataBaseSchema for 10gR1.&#160;&#160; Fabio Maulo has provided some sample code and the steps on <a title="Create missing IDataBaseSchema for submission to NHibernate" href="http://fabiomaulo.blogspot.com/2009/06/from-where-start-to-implements.html" rel="tag">how to create the appropriate metadata</a> for your database and submit it to the NHibernate project for inclusion. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2010/04/nhibernate-2-1-throws-system-invalidcastexception-on-oracle-10g-r1-client/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finally an Oracle x64 client that works on Vista &#8211; AKA Getting Map 2010 x64 running with Oracle&#8230;</title>
		<link>http://www.geospecialling.com/index.php/2009/05/finally-an-oracle-x64-client-that-works-on-vista-aka-getting-map-2010-x64-running-with-oracle/</link>
		<comments>http://www.geospecialling.com/index.php/2009/05/finally-an-oracle-x64-client-that-works-on-vista-aka-getting-map-2010-x64-running-with-oracle/#comments</comments>
		<pubDate>Fri, 22 May 2009 22:01:39 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[x64]]></category>

		<guid isPermaLink="false">http://www.landoris.com/blogs/darrin/index.php/2009/05/finally-an-oracle-x64-client-that-works-on-vista-aka-getting-map-2010-x64-running-with-oracle/</guid>
		<description><![CDATA[As my legion of dedicated readers know, I’m an 64 Bit zealot.&#160; I would love to see a Windows task manager free of *32.&#160; It keeps me up at night…well not really but, whatever. =) Autodesk recently released AutoCAD Map 2010 – the first native x64 release.&#160; How could I resist installing that?&#160; I had [...]]]></description>
			<content:encoded><![CDATA[<p>As my legion of dedicated readers know, I’m an 64 Bit zealot.&#160; I would love to see a Windows task manager free of *32.&#160; It keeps me up at night…well not really but, whatever. =) Autodesk recently released <a title="AutoCAD Map 2010" href="http://usa.autodesk.com/adsk/servlet/index?id=3081357&amp;siteID=123112" target="_blank" rel="tag">AutoCAD Map 2010</a> – the first native x64 release.&#160; How could I resist installing that?&#160; I had this funny feeling I would regret this decision.&#160; Somehow, somewhere I just knew I would end up in <a title="Vista Oracle Driver Hell" href="http://www.webrade.com/blogs/darrin/2008/10/23/OracleClientODACOnVistaX64MostlyWorkingFinally.aspx" target="_blank" rel="tag">Vista Oracle Driver Hell</a> once again.&#160; So I installed Map 2010, started it up and tried to connect to my Oracle server.&#160; You guessed it.&#160; Connection Failed.</p>
<p>The problem is this.&#160;&#160; x64 Applications cannot use the x86 driver.&#160; In my previous attempts to get basic Oracle/ODP connectivity on my x64 Vista machine I ended up running the 11g x86 Oracle client.&#160; Today I was back to the Oracle download site – and lookie lookie.&#160; They’ve released an <a title="Oracle x64 Vista/Windows 2008 Client" href="http://www.oracle.com/technology/software/products/database/oracle11g/111070_win64_2008soft.html" target="_blank" rel="tag">Oracle Server 2008 x64 client</a>!&#160; 2008 is basically Vista so, maybe, just maybe – I thought Oracle will give us some x64 love.&#160; Here are some steps that will help you get running:</p>
<p>First thing is first.&#160; Backup your TNSnames.ora.&#160; Its found in the network\admin folder.&#160; </p>
<p>Next I un-installed the x86 11.1.0.6 client.&#160;&#160; Delete the leftovers with windows explorer.</p>
<p>Next download both the 11.1.0.7 client for both x86 and x64 (yes, we need to run with both…)</p>
<p>First I installed the x64 client.&#160; I like to do full runtime installations.&#160; </p>
<p>Next, I copy my backed up tnsnames.ora into the network\admin folder.</p>
<p>Now fire up Map 2010 x64 – connect to Oracle server – Success!&#160; Happy Happy Days.&#160; Unfortunately, fire up <a title="Toad for Oracle" href="http://www.quest.com/toad-for-oracle/" target="_blank" rel="tag">Toad for Oracle</a> (which is still 32 bit) and it fails with an error of “Cannot find OCI.DLL”.&#160; Doh.</p>
<p>So, I go ahead and install the Oracle 11.1.0.7&#160; x86 client.&#160; I install it to the client_2 folder.&#160; Then copy my tnsnames backup into the network\admin folder in the client_2 folder.&#160; Restart Toad, and success! </p>
<p>Now I want to check one last thing.&#160; Last time I was dealing with this fun issue – I had to set my development projects to only run in x86 mode.&#160; So, I fire up my <a title="FullCircle - Excel to Database / Database to Excel" href="http://www.landoris.com/Solutions/FullCircle/" target="_blank" rel="tag">FullCircle</a> development project and try it out.&#160; Running IIS in x86 mode works.&#160;&#160; Running IIS in x64 mode failed..</p>
<p>The &#8216;MSDAORA&#8217; provider is not registered on the local machine</p>
<p>It seems the Microsoft MSDAORA provider doesn’t exist in x64 – so change your connection to use the Oracle OraOLEDB.Oracle instead and x64 projects run no problem.&#160; It would be perfect to one day get one install that does both x86 and x64 – but for now, I’m content with this setup.</p>
<div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:11f220e3-6c4c-4deb-b192-94e77f7b166c" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/Oracle" rel="tag">Oracle</a>,<a href="http://technorati.com/tags/Vista" rel="tag">Vista</a>,<a href="http://technorati.com/tags/x64" rel="tag">x64</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2009/05/finally-an-oracle-x64-client-that-works-on-vista-aka-getting-map-2010-x64-running-with-oracle/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

