OK, this should be simple. I've just started using ADO in C++, and I'm trying to figure out the best way to insert a record.
At the moment I'm creating a new Recordset and opening it using Open(), but it seems strange to use ADODB::adCmdTable, because it's my understanding that it does a select *. Is there a better option here?
Also, it seems strange to have to pass in the connection string, rather than the connection object that I already have laying around ...
ADODB::_RecordsetPtr prs = NULL;
HRESULT hr = prs.CreateInstance(__uuidof(ADODB::Recordset));
if(!FAILED(hr))
{
const _variant_t vconn = acpAdoConnection->ConnectionString;
prs->Open(
table.c_str(),
vconn,
ADODB::adOpenUnspecified,
ADODB::adLockOptimistic,
ADODB::adCmdTable);
prs->AddNew(fields, values);
}
So what's a better way to insert a single record using ADO?