Click here to Skip to main content
15,906,625 members
Home / Discussions / COM
   

COM

 
GeneralRe: HELPPPP Pin
Christian Graus29-Oct-02 16:47
protectorChristian Graus29-Oct-02 16:47 
GeneralRe: HELPPPP Pin
Stephane Rodriguez.31-Oct-02 5:38
Stephane Rodriguez.31-Oct-02 5:38 
GeneralRe: HELPPPP Pin
Christian Graus31-Oct-02 9:43
protectorChristian Graus31-Oct-02 9:43 
GeneralRe: HELPPPP Pin
Renjith Ramachandran1-Nov-02 6:45
Renjith Ramachandran1-Nov-02 6:45 
GeneralProblem using IStorage::CreateStream() Pin
Xeena28-Oct-02 2:09
Xeena28-Oct-02 2:09 
GeneralRe: Problem using IStorage::CreateStream() Pin
ian mariano29-Oct-02 2:37
ian mariano29-Oct-02 2:37 
GeneralRe: Problem using IStorage::CreateStream() Pin
sajal5-Nov-02 3:24
sajal5-Nov-02 3:24 
QuestionHow to build CCommand from IRowset* Pin
Rohit27-Oct-02 20:18
Rohit27-Oct-02 20:18 
Hi All,

I was trying to write component in which I perform database access only once and return the IRowset* to client. In subsequent client requests, CCommand is built using client given IRowset* without making d/b connection again.

Here is how it goes.
I built CCommand<Accessor<CMyAccessor> > and Opened it using a CSession-obj and extracted IRowset* and other public members from CCommand. I closed CDataSource,CSession not CCommand.
Later I want to build CCommand<> again by assigning IRowset* etc to it.
The problem is I am able to iterate CCommand but CMyAccessor-members the current record holds are garbage values.

Does anyone know the missing steps? Please let me know!

Here goes the code.. (VC++/ATL/SQL Server OLEDB Driver)
//--------------------------------------------------------
// CCommand members to be used in 2nd section
ICommand *pCommand=0;
IRowset *pRowset=0;
_ATL_ACCESSOR_INFO AccInfo={0};

//---------------------------------------------------
//1st Section opens CCommand using session
//---------------------------------------------------
CDataSource connection;
CSession session;
CCommand<CAccessor<CMyAccessor> > cmd;

// establish connection and session

// command opened successfully
cmd.Open(session,"select * from tab1");

//Extract members
pCommand = cmd.m_spCommand.Detach();
pRowset = cmd.m_spRowset.Detach();
AccInfo.bAutoAccessor =
cmdCalDefault.m_pAccessorInfo->bAutoAccessor;
AccInfo.hAccessor = cmdCalDefault.m_pAccessorInfo->
hAccessor;

cmd.Close(); // do nothing as such
session.Close();
connection.Close();

//---------------------------------------------------
//2nd Section builds CCommand using IRowset*
//---------------------------------------------------
CCommand<CAccessor<CMyAccessor> > cmd2;

//Assign to CCommand
cmd2.m_spCommand = pCommand;
cmd2.m_spRowset = pRowset;
cmd2.m_pAccessorInfo = &AccInfo;
cmd2.m_nAccessors = 1;

// Iteration of cmd2 gives garbage values

//--------------------------------------------------------

Regards
Rohit Arora
VC++ Team Member
rohita@dsrsolutions.com
GeneralCOM freezed Pin
Ph@ntom25-Oct-02 21:05
Ph@ntom25-Oct-02 21:05 
GeneralDesign Question Pin
Simon Steele25-Oct-02 0:02
Simon Steele25-Oct-02 0:02 
GeneralRe: Design Question Pin
Daniel Turini25-Oct-02 0:17
Daniel Turini25-Oct-02 0:17 
GeneralRe: Design Question Pin
Simon Steele25-Oct-02 1:34
Simon Steele25-Oct-02 1:34 
GeneralRe: Design Question Pin
Stephane Rodriguez.25-Oct-02 0:29
Stephane Rodriguez.25-Oct-02 0:29 
GeneralRe: Design Question Pin
Simon Steele25-Oct-02 1:25
Simon Steele25-Oct-02 1:25 
GeneralRe: Design Question Pin
Stephane Rodriguez.25-Oct-02 1:36
Stephane Rodriguez.25-Oct-02 1:36 
GeneralRe: Design Question Pin
Len Holgate6-Nov-02 0:09
Len Holgate6-Nov-02 0:09 
GeneralFinding COM objects Pin
thowra24-Oct-02 10:29
thowra24-Oct-02 10:29 
GeneralRe: Finding COM objects Pin
Daniel Turini25-Oct-02 0:22
Daniel Turini25-Oct-02 0:22 
GeneralRe: Finding COM objects Pin
thowra31-Oct-02 4:33
thowra31-Oct-02 4:33 
Generalerror when doing invokehelper.. Pin
BK Pradeep24-Oct-02 1:15
BK Pradeep24-Oct-02 1:15 
Questionhow to pass a struct to com Pin
zwzcode23-Oct-02 22:22
zwzcode23-Oct-02 22:22 
AnswerRe: how to pass a struct to com Pin
Simon.W24-Oct-02 1:30
Simon.W24-Oct-02 1:30 
GeneralBSTR string as output parameter Pin
Huu Pham23-Oct-02 16:41
Huu Pham23-Oct-02 16:41 
GeneralRe: BSTR string as output parameter Pin
Steve S24-Oct-02 2:56
Steve S24-Oct-02 2:56 
GeneralMax Length of BSTR Pin
nativespirits23-Oct-02 10:43
nativespirits23-Oct-02 10:43 

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.