cancel
Showing results for 
Search instead for 
Did you mean: 

Program fails with weird error

oneeyeman1
Participant
0 Kudos

Hi, ALL,

I hope this is the proper place... 😉

I have a Windows 10 VM where I installed SQL Anywhere 17.0.

What I'm now trying to do is to connect to it with ODBC driver from my C++ program.

Connection is successful, however after that I try to execute following:

[code]

for( int i = 0; i < 5; i++ )
{
catalog[i].TargetType = SQL_C_WCHAR;
catalog[i].BufferLength = ( bufferSize + 1 );
catalog[i].TargetValuePtr = malloc( sizeof( unsigned char ) * catalog[i].BufferLength );
ret = SQLBindCol( m_hstmt, (SQLUSMALLINT) i + 1, catalog[i].TargetType, catalog[i].TargetValuePtr, catalog[i].BufferLength, &( catalog[i].StrLen_or_Ind ) );
if( ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO )
{
GetErrorMessage( errorMsg, 1 );
result = 1;
break;
}
}

[/code]


Running this code fails with the error HY090 (Invalid string or buffer length).

According to MSDN, this error is returned when the BufferLength parameter is less than 0 or if the driver is 2,x and not 3.x version. Both cases are not true here.

Could someone please explain what is happenning? Did I hit some kind of bug in the driver?

The code is for preparation to run the SQLTables() function.

I can probably work-around it with a straight up query, but...

Thank you.

P.S. Forgot to say - using MSVC 2017.

chris_keating
Advisor
Advisor
0 Kudos

This is the proper place. Although, the SQL Anywhere Forum is a more active user community for SQL Anywhere in case you do not get an answer here.

Can you confirm the version and build you are using? I tried this with the latest SQL Anywhere 17 software and cannot reproduce this issue. My test is based on the SQLTables Function documentation Example.

oneeyeman1
Participant
0 Kudos
chris.keating

Thx for the reply.

Running "SELECT @@version;" in the ISQL yields

17.0.10.6089.

Let me know f that is not enough.

:

And yes - I'm basing it on the same code as you.

chris_keating
Advisor
Advisor
0 Kudos

I have not had any issues with this in the version you cited.

  • Is the buffer size the same as in the SQLTables example?
  • What C++ tooling are you using i.e., Visual Studio?
  • Are you targeting 64 bit?
  • Are you developing for Wide i.e., SQLConnectW vs SQLConnectA (you may be calling SQLConnect and allowing the compile options handle this so check your project configuration)
  • And to confirm, is the SQLBindCol that reports this error correct? Does it occur on the first iteration?
oneeyeman1
Participant
0 Kudos

chris.keating ,

See answers below:

1.Yes it is the same. And I didn't have any issues with any other DBMSes.

2.MSVC 2017 Free Edition.

3.Building the app as 32 bit for now.

4.I did define UNICODE in my solution.

5.It occur on the first iteration. And yes - it is correct. No issues with SQL Server.

Thank you.

chris_keating
Advisor
Advisor
0 Kudos

I am not able to reproduce this using the SQLTables code sample. If you have support, you may want to consider pursuing a support incident. If not, an ODBC trace might provide insight into the problem source.

chris_keating
Advisor
Advisor
0 Kudos

Are you able to share your project (or a pared down one) that shows this issue? Perhaps I could reproduce this issue using it.

Accepted Solutions (0)

Answers (0)