473,378 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 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 2506
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Joe | last post by:
Python 2.4 Windows XP SP2 MS Access 2000 mx.ODBC 2.0.7 Problem data truncation occuring (here's the actual error message): mxODBC.Warning: ('01004', 5, ' String data, right truncated on...
1
by: James | last post by:
Hello group: I guessing there is no way to create an OLEDB linked table in Access to SQL Server, am I correct? Basically, I've currently migrated one of my Access database tables to SQL Server,...
7
by: Joe | last post by:
I am using Access 2003 and are linking to an Oracle 9i ODBC datasource (using Oracle ODBC drivers). After linking the tables in Access, I inspect the data contained in the linked tables. For...
23
by: Davey | last post by:
How do I display an integer in binary format in C? e.g. 4 displayed as "100"
15
by: T Koster | last post by:
Hi group, I'm having some difficulty figuring out the most portable way to read 24 bits from a file. This is related to a Base-64 encoding. The file is opened in binary mode, and I'm using...
0
by: Richard Marsden | last post by:
I'm having a lot of trouble writing large chunks of binary data (tests are in the range of 16-512K, but we need support for large longblobs) to MySQL using ODBC. Database is local on a W2K system,...
3
by: Chris | last post by:
Hi all, I am trying to use System.Data.ODBC to insert a file into a binary field in SQL Server 2000. Now, before you yell at me, the reason I am doing this is that I am only writing intitial...
9
by: craig.overton | last post by:
All, I am currently developing an FTP class in VB.NET. It's kid tested, mother approved when trying to access an FTP Server on a Windows box meaning I can connect, run commands, upload and...
23
by: ShaneO | last post by:
Hello, I wish to extract embedded string data from a file using a Binary Read method. The following code sample is used in VB.NET and similar code is used in VB6 - (Assume variable...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.