Click here to Skip to main content
15,913,854 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalpl help me! Struggling for days. Problem with ADOs & Binary data insertion Pin
6-May-01 21:02
suss6-May-01 21:02 
GeneralRe: pl help me! Struggling for days. Problem with ADOs & Binary data insertion Pin
l a u r e n6-May-01 21:10
l a u r e n6-May-01 21:10 
GeneralRe: pl help me! Struggling for days. Problem with ADOs & Binary data insertion Pin
6-May-01 22:59
suss6-May-01 22:59 
GeneralRe: pl help me! Struggling for days. Problem with ADOs & Binary data insertion Pin
l a u r e n7-May-01 5:40
l a u r e n7-May-01 5:40 
GeneralRe: pl help me! Struggling for days. Problem with ADOs & Binary data insertion Pin
#realJSOP7-May-01 2:55
professional#realJSOP7-May-01 2:55 
GeneralRe: pl help me! Struggling for days. Problem with ADOs & Binary data insertion Pin
l a u r e n7-May-01 5:36
l a u r e n7-May-01 5:36 
GeneralRe: pl help me! Struggling for days. Problem with ADOs & Binary data insertion Pin
#realJSOP7-May-01 6:02
professional#realJSOP7-May-01 6:02 
GeneralRe: pl help me! Struggling for days. Problem with ADOs & Binary data insertion Pin
Ajit Jadhav7-May-01 7:10
Ajit Jadhav7-May-01 7:10 
Addressed below is a subset of your problem. Essentially, first, you are getting a byte array data typecast to char* and hence the trouble.

0. Use BT_BYREF|VT_UI1 *and* pbVal.

I bet this will work because VT_BYREF|VT_I1 maps to char*. (Meaning, a C-String to be ended at the first null character).

1. For another clean solution. (Divide the work between you and the dll guy):
- HGLOBAL hG = GlobalAlloc( GPTR, 192 );
- CreateStreamOnHGlobal gives you a pStream
- Use CComVariant::ReadFromStream
- Release pStream and hG correctly, later.

2. Or, you can hack like this:
::SysAllocByteLen(192 bytes) to allocate a BSTR yourself.
memcpy your data into BSTR
Encapsulate this BSTR into CComVariant.
Release SysFreeString the BSTR later

I think solution 0 above should solve your problem completely. If not, try 1. If 1 doesn't work, 2. also will not work, and it will be time to focus on ADO/Access interaction rather than CComVariant.

But, if ADO/Access is graceful enough about string lengths and all, I am betting, it's just the issue of data types, and solution 0 will take care of it.

-------
Nature, to be commanded, must be obeyed. (Francis Bacon)
Nature, to be apprehended, must be obeyed. (Ayn Rand)

GeneralRe: pl help me! Struggling for days. Problem with ADOs & Binary data insertion Pin
Ajit Jadhav7-May-01 7:26
Ajit Jadhav7-May-01 7:26 
GeneralRe: pl help me! Struggling for days. Problem with ADOs & Binary data insertion Pin
7-May-01 19:15
suss7-May-01 19:15 
GeneralTrimming spaces in a BSTR value Pin
yamini6-May-01 19:34
yamini6-May-01 19:34 
GeneralFinding coordinates of Focus rectangle Pin
6-May-01 19:33
suss6-May-01 19:33 
GeneralRe: Finding coordinates of Focus rectangle Pin
Christian Graus6-May-01 19:51
protectorChristian Graus6-May-01 19:51 
GeneralRe: Finding coordinates of Focus rectangle Pin
6-May-01 20:03
suss6-May-01 20:03 
GeneralRe: Finding coordinates of Focus rectangle Pin
6-May-01 20:38
suss6-May-01 20:38 
GeneralRe: Finding coordinates of Focus rectangle Pin
Christian Graus6-May-01 20:49
protectorChristian Graus6-May-01 20:49 
GeneralRe: Finding coordinates of Focus rectangle Pin
6-May-01 21:18
suss6-May-01 21:18 
GeneralRe: Finding coordinates of Focus rectangle Pin
#realJSOP7-May-01 1:09
professional#realJSOP7-May-01 1:09 
GeneralFTP Question Pin
Cabadam6-May-01 18:13
Cabadam6-May-01 18:13 
GeneralRe: FTP Question Pin
l a u r e n6-May-01 21:04
l a u r e n6-May-01 21:04 
GeneralRe: FTP Question Pin
Cabadam7-May-01 15:00
Cabadam7-May-01 15:00 
GeneralRe: FTP Question Pin
l a u r e n7-May-01 21:54
l a u r e n7-May-01 21:54 
GeneralRe: FTP Question Pin
Cabadam8-May-01 1:52
Cabadam8-May-01 1:52 
GeneralLauch Internet Explorer Pin
6-May-01 10:23
suss6-May-01 10:23 
GeneralRe: Lauch Internet Explorer Pin
Christian Graus6-May-01 12:04
protectorChristian Graus6-May-01 12:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.