Article ID: 190981
Article Last Modified on 3/2/2005
CCommand<CNoAccessor> cmd;
CCommand<CNoAccessor, CNoRowset>If, for some reason, you need to specify CNoAccessor but still want some of the functionality of the CRowset class, derive a new class from CRowset and override any functions that rely on an accessor.
#include <atlbase.h>
#include <atldbcli.h>
int main(int argc, char* argv[])
{
HRESULT hr;
CoInitialize(NULL);
CDataSource ds;
CSession sn;
hr = ds.OpenFromInitializationString(
L"Provider=MSDASQL;Data Source=YourDSN");
hr = sn.Open(ds);
CCommand<CNoAccessor, CNoRowset> cmd;
CDBPropSet ps(DBPROPSET_ROWSET);
ps.AddProperty(DBPROP_IRowsetChange, true);
ps.AddProperty(DBPROP_UPDATABILITY, DBPROPVAL_UP_DELETE);
hr = cmd.Open(sn, "INSERT INTO Table1 VALUES('Col1Value',
'Col2Value')", &ps , NULL, DBGUID_DBSQL, false);
// No returned results so need to bind anything
cmd.Close();
return 0;
}
Keywords: kbconsumer kbdatabase kbtemplate kbprb kbdtl kbmdacnosweep KB190981