Click here to Skip to main content
16,011,383 members
Home / Discussions / Database
   

Database

 
GeneralAccess Setting Options Programactically Pin
Hyien14-Oct-02 5:16
Hyien14-Oct-02 5:16 
QuestionHow to Convert object that selected from SQL Sever to a DataTime? Pin
14-Oct-02 2:25
suss14-Oct-02 2:25 
AnswerRe: How to Convert object that selected from SQL Sever to a DataTime? Pin
Nick Parker14-Oct-02 2:31
protectorNick Parker14-Oct-02 2:31 
GeneralSqlDataReader : I need to assign retrieved value to C++ variable Pin
Doug13-Oct-02 13:27
Doug13-Oct-02 13:27 
GeneralRe: SqlDataReader : I need to assign retrieved value to C++ variable Pin
Nick Parker14-Oct-02 2:37
protectorNick Parker14-Oct-02 2:37 
GeneralRe: SqlDataReader : I need to assign retrieved value to C++ variable Pin
Doug15-Oct-02 12:15
Doug15-Oct-02 12:15 
GeneralRe: SqlDataReader : I need to assign retrieved value to C++ variable Pin
Nick Parker15-Oct-02 16:38
protectorNick Parker15-Oct-02 16:38 
GeneralRe: SqlDataReader : I need to assign retrieved value to C++ variable Pin
Doug16-Oct-02 12:47
Doug16-Oct-02 12:47 
Hi Nick

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
Generalmsado15.dll Pin
stevenson11-Oct-02 20:11
stevenson11-Oct-02 20:11 
GeneralRe: msado15.dll Pin
Michael P Butler12-Oct-02 1:55
Michael P Butler12-Oct-02 1:55 
GeneralQuestion about Transact SQL Pin
tongc11-Oct-02 6:38
tongc11-Oct-02 6:38 
GeneralRe: Question about Transact SQL Pin
Richard Deeming11-Oct-02 7:10
mveRichard Deeming11-Oct-02 7:10 
GeneralRe: Question about Transact SQL Pin
tongc11-Oct-02 13:48
tongc11-Oct-02 13:48 
GeneralRe: Question about Transact SQL Pin
Richard Deeming13-Oct-02 22:47
mveRichard Deeming13-Oct-02 22:47 
GeneralSQL Suggestions. Pin
Chris Meech11-Oct-02 4:24
Chris Meech11-Oct-02 4:24 
GeneralRe: SQL Suggestions. Pin
Jon Hulatt11-Oct-02 5:52
Jon Hulatt11-Oct-02 5:52 
GeneralRe: SQL Suggestions. Pin
Richard Deeming11-Oct-02 7:23
mveRichard Deeming11-Oct-02 7:23 
GeneralRe: SQL Suggestions. Pin
Chris Meech15-Oct-02 3:36
Chris Meech15-Oct-02 3:36 
GeneralFast SELECT Count Pin
Luca Leonardo Scorcia11-Oct-02 3:12
professionalLuca Leonardo Scorcia11-Oct-02 3:12 
GeneralRe: Fast SELECT Count Pin
Jon Hulatt11-Oct-02 3:42
Jon Hulatt11-Oct-02 3:42 
GeneralRe: Fast SELECT Count Pin
Daniel Turini11-Oct-02 3:52
Daniel Turini11-Oct-02 3:52 
GeneralRe: Fast SELECT Count Pin
Jon Hulatt11-Oct-02 4:23
Jon Hulatt11-Oct-02 4:23 
GeneralRe: Fast SELECT Count Pin
Luca Leonardo Scorcia11-Oct-02 6:55
professionalLuca Leonardo Scorcia11-Oct-02 6:55 
GeneralRe: Fast SELECT Count Pin
Daniel Turini14-Oct-02 0:55
Daniel Turini14-Oct-02 0:55 
QuestionOnly 255 char? Pin
Rickard Andersson2010-Oct-02 21:30
Rickard Andersson2010-Oct-02 21:30 

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.