471,119 Members | 1,365 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,119 software developers and data experts.

Odbc - binding sql server binary field to a wide char field only returns 1/2 the daat

Hi ,
Have a Visual C++ app that use odbc to access sql server database.
Doing a select to get value of binary field and bind a char to that
field as follows , field in database in binary(16)

char lpResourceID[32+1];
rc = SQLBindCol(hstmt, 1, SQL_C_CHAR, &lpResourceID,
RESOURCE_ID_LEN_PLUS_NULL , &nLen1);

and this works fine , however trying to move codebase to UNICODE an
tested the following

WCHAR lpResourceID[32+1];
rc = SQLBindCol(hstmt, 1, SQL_W_CHAR, &lpResourceID,
RESOURCE_ID_LEN_PLUS_NULL , &nLen1);
but only returns 1/2 the data .

Any ideas , thoughts this would work fine , nit sure why loosing data
All ideas welcome.

JOhn

Jul 23 '05 #1
2 2421
John H (jj*******@yahoo.co.uk) writes:
Have a Visual C++ app that use odbc to access sql server database.
Doing a select to get value of binary field and bind a char to that
field as follows , field in database in binary(16)

char lpResourceID[32+1];
rc = SQLBindCol(hstmt, 1, SQL_C_CHAR, &lpResourceID,
RESOURCE_ID_LEN_PLUS_NULL , &nLen1);

and this works fine , however trying to move codebase to UNICODE an
tested the following

WCHAR lpResourceID[32+1];
rc = SQLBindCol(hstmt, 1, SQL_W_CHAR, &lpResourceID,
RESOURCE_ID_LEN_PLUS_NULL , &nLen1);
but only returns 1/2 the data .


Looking in the MDAC Books Online, I see that the fourth argument is a
size in bytes. Thus for Unicode, you say 2 * RESOURCE_ID_LEN_PLUS_NULL.
(Make sure that your buffer is also that size!)

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #2
Hi,
Thanks very much.
Should have figured it out myself!.

JOhn
Erland Sommarskog wrote:
John H (jj*******@yahoo.co.uk) writes:
Have a Visual C++ app that use odbc to access sql server database.
Doing a select to get value of binary field and bind a char to that
field as follows , field in database in binary(16)

char lpResourceID[32+1];
rc = SQLBindCol(hstmt, 1, SQL_C_CHAR, &lpResourceID,
RESOURCE_ID_LEN_PLUS_NULL , &nLen1);

and this works fine , however trying to move codebase to UNICODE an
tested the following

WCHAR lpResourceID[32+1];
rc = SQLBindCol(hstmt, 1, SQL_W_CHAR, &lpResourceID,
RESOURCE_ID_LEN_PLUS_NULL , &nLen1);
but only returns 1/2 the data .
Looking in the MDAC Books Online, I see that the fourth argument is a
size in bytes. Thus for Unicode, you say 2 *

RESOURCE_ID_LEN_PLUS_NULL. (Make sure that your buffer is also that size!)

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp


Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Joe | last post: by
23 posts views Thread by Davey | last post: by
15 posts views Thread by T Koster | last post: by
reply views Thread by Richard Marsden | last post: by
3 posts views Thread by Chris | last post: by
23 posts views Thread by ShaneO | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.