I need to get the DB Literals for a data source from the connection string in
a native C++ app using COM.
I've tried opening the schema with adSchemaDBInfoLiterals and it appears to
return values (field count is 7) but when I try to access a field I get error
800a0cc1 "Item cannot be found in the collection corresponding to the
requested name or ordinal"
This is the basic code...can anyone see what's wrong?
_ConnectionPtr pConnection = NULL;
_RecordsetPtr pRstSchema = NULL;
HRESULT hr = S_OK;
_bstr_t strCnn(strConnectString.c_str());
try
{
// Open connection.
TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
pConnection->Open (strCnn, "", "", adConnectUnspecified);
pRstSchema = pConnection->OpenSchema(adSchemaDBInfoLiterals);
pRstSchema->MoveFirst();
while(!(pRstSchema->IsEOF))
{
CString scnt;
scnt.Format("count is %d",pRstSchema->Fields->Count);
MessageBox(NULL,scnt,"count",0); // shows count as 7
// This line causes the error
MessageBox(NULL,(char*)pRstSchema->Fields->Item[0]->Name,"item 1",0);
|