{"id":68,"date":"2003-11-07T20:16:00","date_gmt":"2003-11-07T20:16:00","guid":{"rendered":"http:\/\/jclark.org\/weblog\/Programming\/worstbugfix.html"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-30T04:00:00","slug":"worstbugfix","status":"publish","type":"post","link":"https:\/\/jclark.org\/weblog\/2003\/11\/07\/worstbugfix\/","title":{"rendered":"Worst. Bugfix. Ever."},"content":{"rendered":"<p>I hope that none of you ever, <strong>ever<\/strong> have to deal with Sybase <span class=\"caps\">ASE ODBC<\/span>\/ADO drivers.  Nevertheless, I&#8217;m going to document a bug (and a fix\/workaround) for using Sybase with Microsoft <span class=\"caps\">ADO,<\/span> because I still can&#8217;t believe it.<\/p>\n<p>I first used <span class=\"caps\">ADO<\/span> against a Sybase server about 6 years ago, on a major website project.  Over the years, I (and other members of my team) have found that every version of the <span class=\"caps\">ADO<\/span>\/ODBC drivers has various issues when used with <span class=\"caps\">MSADO.  <\/span>Each new release of <span class=\"caps\">ADO<\/span> and\/or Sybase Drivers seems to change subtle behaviors in <span class=\"caps\">ADO.  <\/span>We did identify a single version (11.004, I think) that work exactly as it should.  Subsequent versions had bugs, so we stuck with what worked.<\/p>\n<p>We recently deployed all new webserver hardware for that original website project.  It&#8217;s an important website, it processes $12-$15 Billion (yes, that&#8217;s a B) in transactions monthly.  Needless to say, I spent alot of time installing and testing.  Now, the server admins put a new version of the Sybase drivers on ther servers.  I was hesitant, but was told that this version worked correctly.  And in my testing, it did.<\/p>\n<p>Until we deployed.  Seems there was one function I didn&#8217;t test, which used <span class=\"caps\">ADO<\/span>&#8216;s .UpdateBatch() against a Recordset opened with a client-side cursor.  Shame on me for not testing it; nevertheless, the .UpdateBatch() was failing.  Remembering similar issues from the bad-old days of driver shuffling, I tried switching to a server-side cursor.  This fixed the problem.  Unfortunately, it introduced another&#8230; the Sybase server side cursor doesn&#8217;t support Recordset filtering (and of course, the Client-side cursor library does).<\/p>\n<p>So now, I was officially damned-if-I-do, damned-if-I-don&#8217;t.  I immediately (well, right after some choice words) did what any good developer would do&#8230; I Googled.  And lo, Google was good to me, for I found what I needed immediately.  And I was shocked.<\/p>\n<p>The post I found said that you could correct the &#8216;UpdateBatch failing on client-side cursors&#8217; issue by adding the following line to your data source&#8217;s section of your <span class=\"caps\">ODBC<\/span>.ini file:<\/p>\n<blockquote><p><code>WorkArounds2=24<\/code><\/p><\/blockquote>\n<p>Now, I don&#8217;t know if this affects the Sybase software or the Microsoft <span class=\"caps\">ADO<\/span> software, but what we have here is a hack.  An undocumented hack at that.  Why this isn&#8217;t a configurable option on the <span class=\"caps\">ADO<\/span> library or the <span class=\"caps\">OLEDB<\/span>\/ODBC driver is beyond me.  But that&#8217;s not the worst part.  The person who posted this nugget was in fact posting a solution to a problem they had themselves posted&#8230; and they found this answer in a newsgroup post from <strong>1998<\/strong>.  Why is this nasty hack still needed, <em>five years later<\/em>?<\/p>\n<p>So, for the search engines, the above <em>hack<\/em> will fix and <span class=\"caps\">ADO<\/span> failure cause when trying to run .UpdateBatch against a client-side (adUseClient) Recordset with Sybase <span class=\"caps\">ASE<\/span> drivers.  The error message is:<\/p>\n<blockquote>\n\n<pre>\nRun-time error '2147467259 (80004005)';\nData provider or other service returned an E-FAIL status.\n<\/pre><\/blockquote>\n<p>You may also see a message that the error was raised by the Microsoft Cursor Engine.  Also note, <span class=\"caps\">ODBC<\/span>.ini now lives in the registry, at <span class=\"caps\">HKLM<\/span>\/Software\/ODBC.ini.<\/p>\n<p>      <\/p>","protected":false},"excerpt":{"rendered":"<p>I hope that none of you ever, ever have to deal with Sybase ASE ODBC\/ADO drivers. Nevertheless, I&#8217;m going to document a bug (and a fix\/workaround) for using Sybase with Microsoft ADO, because I still can&#8217;t believe it. I first used ADO against a Sybase server about 6 years ago, on a major website project. [&hellip;]<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-68","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/jclark.org\/weblog\/wp-json\/wp\/v2\/posts\/68","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jclark.org\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jclark.org\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jclark.org\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jclark.org\/weblog\/wp-json\/wp\/v2\/comments?post=68"}],"version-history":[{"count":0,"href":"https:\/\/jclark.org\/weblog\/wp-json\/wp\/v2\/posts\/68\/revisions"}],"wp:attachment":[{"href":"https:\/\/jclark.org\/weblog\/wp-json\/wp\/v2\/media?parent=68"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jclark.org\/weblog\/wp-json\/wp\/v2\/categories?post=68"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jclark.org\/weblog\/wp-json\/wp\/v2\/tags?post=68"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}