473,657 Members | 2,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(hstm t, 1, SQL_C_CHAR, &lpResourceI D,
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(hstm t, 1, SQL_W_CHAR, &lpResourceI D,
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 2515
John H (jj*******@yaho o.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(hstm t, 1, SQL_C_CHAR, &lpResourceI D,
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(hstm t, 1, SQL_W_CHAR, &lpResourceI D,
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****@sommarsk og.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*******@yaho o.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(hstm t, 1, SQL_C_CHAR, &lpResourceI D,
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(hstm t, 1, SQL_W_CHAR, &lpResourceI D,
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****@sommarsk og.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
1836
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 column number 3 (Expr1002)', 3326)
1
7586
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, and they are linked via an ODBC connection. I'm am attempting to make the logon to SQL server transparent so the users are never prompted to logon. I can easily create an ADO connection object in a procedure to open a connection with the proper...
7
11826
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 tables that involve a number field as the primary key, the data is returned successfully. For tables that involve a character field (e.g. CHAR(3) or VARCHAR(10)) as the primary key, I have the correct number of rows returned, but the data displayed...
23
5269
by: Davey | last post by:
How do I display an integer in binary format in C? e.g. 4 displayed as "100"
15
2021
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 fread to read three bytes from it. The question is though, where should fread put this? I have considered two alternatives, but neither seem like a good idea: In most cases, the width of a char is 8 bits, so an array of 3 chars
0
1646
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, but I have to support all modern Windows systems, and a variety of ODBC configurations. (I'll be testing against multiple ODBC databases soon - but development is against MySQL) I've been able to adapt some example code that executes a...
3
2912
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 code against SQL, but this app will need to be able to run against any ODBC compliant DB, so I am also not using stored procedures. I have tangles with this for hours, but I cannot seem to figure out how to just read the contents of a file off...
9
8315
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 download a file no problem. My issues come when I try to use the same class with the same commands to access an FTP server on a UNIX box. I can connect and login just fine, but after that all my commands come back "500 'PWD': command not understood."....
23
2822
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 declarations etc.) FileOpen(iFileIn, sInputFile, OpenMode.Binary, OpenAccess.Read)
0
8829
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8734
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8508
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7341
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5633
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4164
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.