<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: ODBC failure on basic call in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14378898#M4940720</link>
    <description>&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/2817"&gt;@Jack&lt;/a&gt;_shueler, take a look at &lt;A href="https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqltables-function?view=sql-server-ver17#example" target="_blank"&gt;https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqltables-function?view=sql-server-ver17#example&lt;/A&gt;</description>
    <pubDate>Tue, 21 Apr 2026 00:33:51 GMT</pubDate>
    <dc:creator>oneeyeman1</dc:creator>
    <dc:date>2026-04-21T00:33:51Z</dc:date>
    <item>
      <title>ODBC failure on basic call</title>
      <link>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaq-p/14375509</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for( int i = 0; i &amp;lt; 5; i++ )&lt;BR /&gt;{&lt;BR /&gt;catalog[i].TargetType = SQL_C_WCHAR;&lt;BR /&gt;catalog[i].BufferLength = ( bufferSize + 1 );&lt;BR /&gt;catalog[i].TargetValuePtr = malloc( sizeof( unsigned char ) * catalog[i].BufferLength );&lt;BR /&gt;ret = SQLBindCol( m_hstmt, (SQLUSMALLINT) i + 1, catalog[i].TargetType, catalog[i].TargetValuePtr, catalog[i].BufferLength, &amp;amp;( catalog[i].StrLen_or_Ind ) );&lt;BR /&gt;if( ret != SQL_SUCCESS &amp;amp;&amp;amp; ret != SQL_SUCCESS_WITH_INFO )&lt;BR /&gt;{&lt;BR /&gt;GetErrorMessage( errorMsg, STMT_ERROR );&lt;BR /&gt;result = 1;&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code fails with HY090.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However it didn't fail with any other DBMS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im running SQL Anywhere 17.0 with the driver 17.0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2026 23:58:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaq-p/14375509</guid>
      <dc:creator>oneeyeman1</dc:creator>
      <dc:date>2026-04-15T23:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: ODBC failure on basic call</title>
      <link>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14375545#M4940464</link>
      <description>&lt;P&gt;I don't see anything specific in this code snippet nor can I reproduce the error in an more complete implementation. I would suggest getting an ODBC trace. In that trace, please ensure that the&amp;nbsp;SQL_ATTR_ODBC_VERSION is set to&amp;nbsp;SQL_OV_ODBC3 (SQLSetEnvAttr)&amp;nbsp; and then look for the&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;DIAG [HY090] [Microsoft][ODBC Driver Manager] Invalid string or buffer length (0)&lt;/P&gt;&lt;P&gt;to confirm what ODBC function encounters the error. A call to SQLBindCol has a context for the error related to the&amp;nbsp;&lt;SPAN&gt;BufferLength being not negative.&amp;nbsp; If it is coming from a different ODBC function, share what that function is and how your application has implemented it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This really does not appear to be a SQLA driver issue. If you can share the trace, we can use ODBCTest to replay the ODBC calls leading to the error.&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2026 03:34:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14375545#M4940464</guid>
      <dc:creator>chris_keating</dc:creator>
      <dc:date>2026-04-16T03:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: ODBC failure on basic call</title>
      <link>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14375603#M4940470</link>
      <description>&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/191873"&gt;@chris_keating&lt;/a&gt;, I generated the log file. Please do let me know how and where to upload/send it. This site interface is not designed to do that. Thx.</description>
      <pubDate>Thu, 16 Apr 2026 05:13:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14375603#M4940470</guid>
      <dc:creator>oneeyeman1</dc:creator>
      <dc:date>2026-04-16T05:13:57Z</dc:date>
    </item>
    <item>
      <title>Re: ODBC failure on basic call</title>
      <link>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14375611#M4940474</link>
      <description>The code Im trying comes straight from &lt;A href="https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqltables-function?view=sql-server-ver17#example" target="_blank"&gt;https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqltables-function?view=sql-server-ver17#example&lt;/A&gt;..</description>
      <pubDate>Thu, 16 Apr 2026 05:23:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14375611#M4940474</guid>
      <dc:creator>oneeyeman1</dc:creator>
      <dc:date>2026-04-16T05:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: ODBC failure on basic call</title>
      <link>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14376237#M4940519</link>
      <description>&lt;P&gt;I spoke with a SQL Anywhere ODBC driver developer to confirm what is happening.&amp;nbsp; The buffer is measured in bytes and SQL Anywhere expects the buffer to be an even value when processing wide characters i.e., SQL_C_WCHAR, and sized sufficiently for the value being accessed.&amp;nbsp; In the SQLTables example, it is using SQL_C_CHAR so is not impacted by this.&amp;nbsp; So, use an even value when you are setting the&amp;nbsp;&lt;SPAN&gt;catalog[i].BufferLength with SQL_C_WCHAR.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2026 19:31:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14376237#M4940519</guid>
      <dc:creator>chris_keating</dc:creator>
      <dc:date>2026-04-16T19:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: ODBC failure on basic call</title>
      <link>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14376366#M4940526</link>
      <description>&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/191873"&gt;@chris_keating&lt;/a&gt;, So what should be done? My app is unicode one and so it should work with SQL_W_CHAR... Also as mentioned - SQL Server, PostgreSQL, MySQL and probably SAP ASE (from memory) works correctly. Does using +1 fixes it?</description>
      <pubDate>Thu, 16 Apr 2026 19:25:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14376366#M4940526</guid>
      <dc:creator>oneeyeman1</dc:creator>
      <dc:date>2026-04-16T19:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: ODBC failure on basic call</title>
      <link>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14376406#M4940531</link>
      <description>&lt;LI-CODE lang="c"&gt;// Instead of writing this ...
catalog[i].BufferLength = ( bufferSize + 1 );
// write this ...
// Note that some ODBC drivers have a 2-byte SQLWCHAR (like us) and 
// some ODBC drivers have a 4-byte SQLWCHAR, so write this.
catalog[i].BufferLength = ( characterSize + 1 ) * sizeof(SQLWCHAR);
// Example: for CHAR(10) data, characterSize = 10 and 
// the + 1 accounts for a null terminator.
// Analogously, the following works for non-wide SQLCHAR.
catalog[i].BufferLength = ( characterSize + 1 ) * sizeof(SQLCHAR);
// To generalize the "BufferLength" value ...
characterSize = n; // Ex: 10 for SQL CHAR(10) or VARCHAR(10)
sizeofCharacter = sizeof(SQLWCHAR); //or sizeof(SQLCHAR)
catalog[i].BufferLength = ( characterSize + 1 ) * sizeofCharacter;&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 16 Apr 2026 21:03:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14376406#M4940531</guid>
      <dc:creator>jack_schueler</dc:creator>
      <dc:date>2026-04-16T21:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: ODBC failure on basic call</title>
      <link>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14376556#M4940536</link>
      <description>&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/2817"&gt;@Jack&lt;/a&gt;_shueler, the generalized solution works fine for SQL Anywhere on Windows. Will check ther DBMSes and OSes later. Thx.</description>
      <pubDate>Fri, 17 Apr 2026 04:39:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14376556#M4940536</guid>
      <dc:creator>oneeyeman1</dc:creator>
      <dc:date>2026-04-17T04:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: ODBC failure on basic call</title>
      <link>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14376652#M4940550</link>
      <description>&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/2817"&gt;@Jack&lt;/a&gt;_shueler, I checked and it looks like it works for SQL Server from Windows as well. However, it means that the code I referenced is wrong... Will try to submit to MS...</description>
      <pubDate>Fri, 17 Apr 2026 07:14:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14376652#M4940550</guid>
      <dc:creator>oneeyeman1</dc:creator>
      <dc:date>2026-04-17T07:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: ODBC failure on basic call</title>
      <link>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14377667#M4940616</link>
      <description>&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/2817"&gt;@Jack&lt;/a&gt;_shueler, , it works even on Linux with unixODBC. Thx for the solution.</description>
      <pubDate>Sun, 19 Apr 2026 20:44:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14377667#M4940616</guid>
      <dc:creator>oneeyeman1</dc:creator>
      <dc:date>2026-04-19T20:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: ODBC failure on basic call</title>
      <link>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14378593#M4940709</link>
      <description>Re: Will try to submit to MS. Are you suggesting that Microsoft posted the sample code that you provided? Where did you find it? I am surprised that MS would provide an example that has an odd-length buffer size.</description>
      <pubDate>Mon, 20 Apr 2026 17:14:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14378593#M4940709</guid>
      <dc:creator>jack_schueler</dc:creator>
      <dc:date>2026-04-20T17:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: ODBC failure on basic call</title>
      <link>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14378898#M4940720</link>
      <description>&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/2817"&gt;@Jack&lt;/a&gt;_shueler, take a look at &lt;A href="https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqltables-function?view=sql-server-ver17#example" target="_blank"&gt;https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqltables-function?view=sql-server-ver17#example&lt;/A&gt;</description>
      <pubDate>Tue, 21 Apr 2026 00:33:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14378898#M4940720</guid>
      <dc:creator>oneeyeman1</dc:creator>
      <dc:date>2026-04-21T00:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: ODBC failure on basic call</title>
      <link>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14378907#M4940721</link>
      <description>The referenced web page has a correct example. It uses a 1-byte SQL_C_CHAR (SQLCHAR type). You modified the datatype to 2-byte SQL_C_WCHAR but did not double the buffer length.</description>
      <pubDate>Tue, 21 Apr 2026 01:16:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/odbc-failure-on-basic-call/qaa-p/14378907#M4940721</guid>
      <dc:creator>jack_schueler</dc:creator>
      <dc:date>2026-04-21T01:16:00Z</dc:date>
    </item>
  </channel>
</rss>

