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

C / C++ / MFC

 
QuestionCImageList bug.....or am I just dumb? Pin
Teknofreek16-Oct-02 20:06
Teknofreek16-Oct-02 20:06 
AnswerRe: CImageList bug.....or am I just dumb? Pin
Tomasz Sowinski16-Oct-02 23:31
Tomasz Sowinski16-Oct-02 23:31 
GeneralRe: CImageList bug.....or am I just dumb? Pin
Teknofreek17-Oct-02 10:40
Teknofreek17-Oct-02 10:40 
QuestionHow to detect whether network is available? Pin
Wenrich16-Oct-02 18:36
Wenrich16-Oct-02 18:36 
Generalvectorize a bitmap Pin
bethbyang16-Oct-02 15:34
bethbyang16-Oct-02 15:34 
GeneralRe: vectorize a bitmap Pin
Maximilien16-Oct-02 15:57
Maximilien16-Oct-02 15:57 
GeneralRe: vectorize a bitmap Pin
Anonymous17-Oct-02 16:51
Anonymous17-Oct-02 16:51 
GeneralHeeeeeeeelp: CString and /clr Pin
Doug16-Oct-02 12:50
Doug16-Oct-02 12:50 
Hi Folks

Re: ADO.NET : SqlDataReader : I need to assign retrieved value to C++ variable

I have found the source of the problem expressed in the thread "ADO.NET : SqlDataReader : I need to assign retrieved value to C++ variable":
http://www.codeproject.com/script/comments/forums.asp?forumid=3785#xx309754xx

but do not yet know why it occurs or how I can fix it.

The problem arises with the /clr compiler setting.

Here is the code to illustrate this:

/////////////////////////////////////////////////////////

#include <stdafx.h>
#include <cstdlib>
#include "try_ADONET.h"

//#using <mscorlib.dll>
//#using <system.dll>
//#using <system.data.dll> // This is required for the ADO.NET Provider

using namespace std;
//using namespace System;

int Main()
{
CString busNumberSQL[2];
CString bus = "Hello";
busNumberSQL[1] = bus;

return 0;
}

////////////////////////////////////////////////////////

Without the /clr setting the array of CString busNumberSQL[2] is correctly contructed as is CString bus and the line

busNumberSQL[1] = bus;

works as expected. This can be seen by putting a breakpoint in at

return 0;

and seeing the variables in a Watch. Copy the expanded Watch details (Name, Value & Type) to an EXCEL sheet.
..................

Next, add the compiler switch /clr and rerun the code.

CString bus is constructed correctly BUT something weird happens in the construction of CString busNumberSQL[2].

Now,
busNumberSQL[1] = bus;

results in the address of bus as an integer being assigned to busNumberSQL[1], and look at the Watch details!!

Copy the expanded Watch details (Name, Value & Type) to an EXCEL sheet

Name: busNumberSQL; Value: {Length=2}; Type: ATL::CStringT<char,strtraitmfc<char,atl::chtraitscrt<char> > >[] ...(Note no dimension at end compared to the "no /clr" case.
Next Watch line: [0] 2083454756 __int32
Next Watch line: [1] 3103464 __int32

My conclusion is that busNumberSQL[2] is not an array of CString.

Of course, I need the /clr in order to use ADO.NET!

It seems as though a CString works, but a CString array for some (unknown) cannot even be defined.

Do you have any light for me? (I have not got into your previous post yet on Marshall)

Best regards

Doug.

(In case you are wondering I am very much a beginner with C++ and .NET)




Doug
GeneralRe: Heeeeeeeelp: CString and /clr Pin
Nish Nishant16-Oct-02 19:24
sitebuilderNish Nishant16-Oct-02 19:24 
QuestionSHAutoComplete() where art thou? Pin
Ravi Bhavnani16-Oct-02 12:15
professionalRavi Bhavnani16-Oct-02 12:15 
AnswerRe: SHAutoComplete() where art thou? Pin
Rene De La Garza16-Oct-02 13:12
Rene De La Garza16-Oct-02 13:12 
AnswerRe: SHAutoComplete() where art thou? Pin
Michael Dunn16-Oct-02 18:40
sitebuilderMichael Dunn16-Oct-02 18:40 
AnswerRe: SHAutoComplete() where art thou? Pin
Ravi Bhavnani17-Oct-02 1:00
professionalRavi Bhavnani17-Oct-02 1:00 
GeneralInline functions performance. Pin
Maximilien16-Oct-02 10:47
Maximilien16-Oct-02 10:47 
GeneralRe: Inline functions performance. Pin
Joaquín M López Muñoz16-Oct-02 11:13
Joaquín M López Muñoz16-Oct-02 11:13 
GeneralRe: Inline functions performance. Pin
Marc Clifton16-Oct-02 11:28
mvaMarc Clifton16-Oct-02 11:28 
QuestionHeap Fragmentation? Pin
Member 1035854716-Oct-02 10:28
Member 1035854716-Oct-02 10:28 
AnswerRe: Heap Fragmentation? Pin
Pavel Klocek16-Oct-02 19:26
Pavel Klocek16-Oct-02 19:26 
AnswerRe: Heap Fragmentation? Pin
Tomasz Sowinski16-Oct-02 23:40
Tomasz Sowinski16-Oct-02 23:40 
GeneralCallback and Assembly Pin
S van Leent16-Oct-02 10:16
S van Leent16-Oct-02 10:16 
GeneralRe: Callback and Assembly Pin
Paul M Watt16-Oct-02 10:41
mentorPaul M Watt16-Oct-02 10:41 
GeneralRe: Callback and Assembly Pin
S van Leent16-Oct-02 10:42
S van Leent16-Oct-02 10:42 
GeneralRe: Callback and Assembly Pin
Joaquín M López Muñoz16-Oct-02 12:00
Joaquín M López Muñoz16-Oct-02 12:00 
GeneralRe: Callback and Assembly Pin
S van Leent16-Oct-02 20:57
S van Leent16-Oct-02 20:57 
GeneralShortcut making .ini behaving abnormally Pin
insanely42016-Oct-02 9:56
insanely42016-Oct-02 9:56 

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.