Name: Anonymous 2006-10-04 12:04
Hey guys, I'm having a problem with ADO using C++, can anyone help?
The code is as follows:
But the line marked as FAIL, which is supposed to set the first (and in this case only) parameter to "BM_PRINT" throws an exception with error 0x800a0cc1, "Item cannot be found in the collection corresponding to the requested name or ordinal."
This doesn't make sense to me as I just created the parameter. Any ideas what's going on??
The code is as follows:
_CommandPtr cmd;
cmd.CreateInstance(__uuidof(Command));
cmd->ActiveConnection = con; // con is the connection set up earlier
cmd->CommandType = adCmdText;
cmd->CommandText = "declare @sys_key varchar(10) set @sys_key=? select top 1 [sys_key], [value], [description] from system_directory order by sys_key";
cmd->Parameters->Append(
cmd->CreateParameter(
"@sys_key",
adVarChar,
adParamInput,
10,
NULL
)
);
_variant_t var = "BM_PRINT";
cmd->Parameters->Item[0]->Value = var; // FAIL!
rec = cmd->Execute(NULL, NULL, -1);But the line marked as FAIL, which is supposed to set the first (and in this case only) parameter to "BM_PRINT" throws an exception with error 0x800a0cc1, "Item cannot be found in the collection corresponding to the requested name or ordinal."
This doesn't make sense to me as I just created the parameter. Any ideas what's going on??