Empty string returned when retrieving text field using ODBC (MFC)

Empty string returned when retrieving text field using ODBC (MFC)

am 23.06.2010 14:55:43 von Guillermo

Hello,

I'm trying to get the value of a text field using
CRecordset::GetFieldValue, but it returns an empty string. Changing the
type from TEXT to VARCHAR avoids the problem, but I really need to use
TEXT. Other non-text fields in the record can be retrieved successfully.
Note that the text value is just a 10-character string.

I've tried changing the flags of the data source in ODBC (allow big
results sets, limit column size to signed 32-bit range and others I
don't recall), but it didn't make any difference. Am I doing something
wrong? Is that supported?

I'm using MySQL 5.1.41 with the MyODBC driver 5.1.6 on Windows 7 x86,
Visual C++ 2008 SP1. I can provide a slice of the ODBC log if it can be
useful.

Thanks in advance.
Regards,

Guillermo Miranda.


--
MySQL ODBC Mailing List
For list archives: http://lists.mysql.com/myodbc
To unsubscribe: http://lists.mysql.com/myodbc?unsub=gcdmo-myodbc@m.gmane.org

Re: Empty string returned when retrieving text field using ODBC (MFC)

am 23.06.2010 17:23:26 von Lawrin Novitsky

Hi,

Did you try "handle binary as char" option?

What's a charset of your field? do you set charset in connection string/dsn?

And yes, odbc log would be useful. But the better place for it probably
a bug report would be, not this maillist.

Regards,

Lawrin Novitsky

Guillermo Miranda Álamo wrote:
> Hello,
>
> I'm trying to get the value of a text field using
> CRecordset::GetFieldValue, but it returns an empty string. Changing the
> type from TEXT to VARCHAR avoids the problem, but I really need to use
> TEXT. Other non-text fields in the record can be retrieved successfully.
> Note that the text value is just a 10-character string.
>
> I've tried changing the flags of the data source in ODBC (allow big
> results sets, limit column size to signed 32-bit range and others I
> don't recall), but it didn't make any difference. Am I doing something
> wrong? Is that supported?
>
> I'm using MySQL 5.1.41 with the MyODBC driver 5.1.6 on Windows 7 x86,
> Visual C++ 2008 SP1. I can provide a slice of the ODBC log if it can be
> useful.
>
> Thanks in advance.
> Regards,
>
> Guillermo Miranda.
>
>


--
MySQL ODBC Mailing List
For list archives: http://lists.mysql.com/myodbc
To unsubscribe: http://lists.mysql.com/myodbc?unsub=gcdmo-myodbc@m.gmane.org

Re: Empty string returned when retrieving text field using ODBC (MFC)

am 23.06.2010 17:44:24 von Guillermo

--------------050400090602070408090104
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

On 23/06/2010 17:23, Lawrin Novitsky wrote:
> Hi,
>
> Did you try "handle binary as char" option?
>
> What's a charset of your field? do you set charset in connection
> string/dsn?
>
> And yes, odbc log would be useful. But the better place for it probably
> a bug report would be, not this maillist.
>
> Regards,
>
> Lawrin Novitsky

Hi Lawrin,

I just tried that but it didn't work. The field's charset is utf8_bin. I
wasn't manually specifying the charset in the connection string because
it did work with VARCHAR, I did so, but I keep getting that empty string.

This is the line where I connect to the DB:
db.OpenEx("DSN=mysource;CHARSET=latin1");

Hope it's OK.

I've attached the last lines of the ODBC log. SQL_text_r.LOG is what I
get when the field is a TEXT field, and SQL_varchar_r.LOG when it's a
VARCHAR field. All lines of the log file before what's in the attached
files have been removed as there was no difference between those file
(besides memory addresses).

Thanks
Guillermo.


--------------050400090602070408090104
Content-Type: text/plain;
name="SQL_text_r.LOG"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="SQL_text_r.LOG"

dll_spell_Debug a74-a7c ENTER SQLGetData
HSTMT 0x00805B68
UWORD 2
SWORD 1
PTR 0x023E0468
SQLLEN 2
SQLLEN * 0x0012E18C

dll_spell_Debug a74-a7c EXIT SQLGetData with return code 0 (SQL_SUCCESS)
HSTMT 0x00805B68
UWORD 2
SWORD 1
PTR 0x023E0468 [ 2] "\ 0\ff"
SQLLEN 2
SQLLEN * 0x0012E18C (20)

dll_spell_Debug a74-a7c ENTER SQLGetData
HSTMT 0x00805B68
UWORD 2
SWORD 1
PTR 0x023E0469
SQLLEN 20
SQLLEN * 0x0012E17C

dll_spell_Debug a74-a7c EXIT SQLGetData with return code 0 (SQL_SUCCESS)
HSTMT 0x00805B68
UWORD 2
SWORD 1
PTR 0x023E0469 [ 20] "436F6D6F2065737461\ 0\ff"
SQLLEN 20
SQLLEN * 0x0012E17C (20)

--------------050400090602070408090104
Content-Type: text/plain;
name="SQL_varchar_r.LOG"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="SQL_varchar_r.LOG"

dll_spell_Debug a74-a7c ENTER SQLGetData
HSTMT 0x00805600
UWORD 2
SWORD 1
PTR 0x0063BF98
SQLLEN 65
SQLLEN * 0x0012E18C

dll_spell_Debug a74-a7c EXIT SQLGetData with return code 0 (SQL_SUCCESS)
HSTMT 0x00805600
UWORD 2
SWORD 1
PTR 0x0063BF98 [ 10] "Como estas"
SQLLEN 65
SQLLEN * 0x0012E18C (10)


--------------050400090602070408090104
Content-Type: text/plain; charset=us-ascii


--
MySQL ODBC Mailing List
For list archives: http://lists.mysql.com/myodbc
To unsubscribe: http://lists.mysql.com/myodbc?unsub=gcdmo-myodbc@m.gmane.org
--------------050400090602070408090104--