Click here to Skip to main content
15,910,211 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: is there any lose of value ? Pin
Christian Graus22-Nov-02 13:26
protectorChristian Graus22-Nov-02 13:26 
AnswerRe: is there any lose of value ? Pin
ian mariano28-Oct-02 4:03
ian mariano28-Oct-02 4:03 
Questionis it the right code? Pin
imran_rafique23-Oct-02 16:29
imran_rafique23-Oct-02 16:29 
AnswerRe: is it the right code? Pin
Christian Graus22-Nov-02 13:27
protectorChristian Graus22-Nov-02 13:27 
GeneralCallback in C++ to invoke object in MC++ Pin
Elf17-Oct-02 20:54
Elf17-Oct-02 20:54 
GeneralRe: Callback in C++ to invoke object in MC++ Pin
Nish Nishant17-Oct-02 21:10
sitebuilderNish Nishant17-Oct-02 21:10 
Generalchanging RTF hyperlink appearance w/ C++ .NET Pin
group_captain_mandrake17-Oct-02 17:54
group_captain_mandrake17-Oct-02 17:54 
GeneralCalling Nishant S; Nick Parker ; anyone RE CString and /clr Pin
Doug16-Oct-02 12:36
Doug16-Oct-02 12:36 
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: Calling Nishant S; Nick Parker ; anyone RE CString and /clr Pin
Nish Nishant16-Oct-02 19:23
sitebuilderNish Nishant16-Oct-02 19:23 
GeneralRe: Calling Nishant S; Nick Parker ; anyone RE CString and /clr Pin
Doug17-Oct-02 11:09
Doug17-Oct-02 11:09 
GeneralRe: Calling Nishant S; Nick Parker ; anyone RE CString and /clr Pin
Doug17-Oct-02 11:19
Doug17-Oct-02 11:19 
GeneralADO.NET : SqlDataReader : I need to assign retrieved value to C++ variable Pin
Doug13-Oct-02 13:31
Doug13-Oct-02 13:31 
GeneralRe: ADO.NET : SqlDataReader : I need to assign retrieved value to C++ variable Pin
Nish Nishant13-Oct-02 15:05
sitebuilderNish Nishant13-Oct-02 15:05 
GeneralRe: ADO.NET : SqlDataReader : I need to assign retrieved value to C++ variable Pin
Doug13-Oct-02 18:15
Doug13-Oct-02 18:15 
GeneralRe: ADO.NET : SqlDataReader : I need to assign retrieved value to C++ variable Pin
Nick Parker14-Oct-02 8:19
protectorNick Parker14-Oct-02 8:19 
GeneralRe: ADO.NET : SqlDataReader : I need to assign retrieved value to C++ variable Pin
Doug14-Oct-02 10:17
Doug14-Oct-02 10:17 
GeneralRe: ADO.NET : SqlDataReader : I need to assign retrieved value to C++ variable Pin
Doug16-Oct-02 12:40
Doug16-Oct-02 12:40 
GeneralRe: ADO.NET : SqlDataReader : I need to assign retrieved value to C++ variable Pin
Doug15-Oct-02 12:17
Doug15-Oct-02 12:17 
GeneralRe: ADO.NET : SqlDataReader : I need to assign retrieved value to C++ variable Pin
Doug16-Oct-02 12:39
Doug16-Oct-02 12:39 
GeneralUnmanaged Event Pin
ajb10-Oct-02 11:41
ajb10-Oct-02 11:41 
QuestionIncluding Wbemdisp? Pin
EnkelIk9-Oct-02 2:48
EnkelIk9-Oct-02 2:48 
AnswerRe: Including Wbemdisp? Pin
Michael Mac11-Oct-02 2:20
Michael Mac11-Oct-02 2:20 
QuestionHow do I make an assembly? Pin
EnkelIk7-Oct-02 22:31
EnkelIk7-Oct-02 22:31 
AnswerRe: How do I make an assembly? Pin
EnkelIk9-Oct-02 21:56
EnkelIk9-Oct-02 21:56 
Questionhow to? Pin
imran_rafique5-Oct-02 15:27
imran_rafique5-Oct-02 15:27 

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.