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

Managed C++/CLI

 
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 
Hi Nish

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
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 
AnswerRe: how to? Pin
Slayer14-Oct-02 3:09
Slayer14-Oct-02 3:09 
GeneralUsing STL in MC++ Pin
Anonymous2-Oct-02 9:09
Anonymous2-Oct-02 9:09 
GeneralRe: Using STL in MC++ Pin
Alexandru Savescu14-Nov-02 5:42
Alexandru Savescu14-Nov-02 5:42 
QuestionNew line in textbox? Pin
EnkelIk30-Sep-02 20:42
EnkelIk30-Sep-02 20:42 
AnswerRe: New line in textbox? Pin
Christian Graus30-Sep-02 22:55
protectorChristian Graus30-Sep-02 22:55 
AnswerRe: New line in textbox? Pin
group_captain_mandrake17-Oct-02 18:04
group_captain_mandrake17-Oct-02 18:04 
Questionhow to? Pin
imran_rafique29-Sep-02 16:36
imran_rafique29-Sep-02 16:36 
QuestionHOW to creat FileStream? Pin
imran_rafique28-Sep-02 15:31
imran_rafique28-Sep-02 15:31 
Questioncan any body write the syntex of reading and writing the object ito a file ? Pin
imran_rafique27-Sep-02 16:07
imran_rafique27-Sep-02 16:07 
Questionmay i read the same object on network from a file? Pin
imran_rafique26-Sep-02 16:10
imran_rafique26-Sep-02 16:10 
AnswerRe: may i read the same object on network from a file? Pin
Rickard Andersson2026-Sep-02 20:50
Rickard Andersson2026-Sep-02 20:50 

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.