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;

//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 =
AccInfo.hAccessor = cmdCalDefault.m_pAccessorInfo->

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

//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