|
if(FAILED(CoInitializeEx(NULL, COINIT_MULTITHREADED)))
return FALSE;
HRESULT hr;
CLSID g_ClsID;
hr = CLSIDFromProgID(TEXT("ADOCE.Connection.3.1"), &g_ClsID);
hr = CoCreateInstance(g_ClsID, NULL, CLSCTX_INPROC_SERVER, IID__Connection, (LPVOID*) &m_pConn);
hr = m_pConn->put_Provider(L"\\my documents\\myce.sdf");
hr = m_pConn->Open(L"Provider=microsoft.sqlserver.oledb.ce.2.0;Data Source=\\my documents\\myce.sdf",TEXT(""),TEXT(""),adOpenUnspecified);
_Recordset *set=CreateRecordSet(m_pConn);
set->Open(_variant_t(L"insert han (id) values(7)"),_variant_t(m_pConn),adOpenForwardOnly,adLockPessimistic);这样可以增加一条记录
但是用函数set->AddNew(_variant_t(L"id"),_variant_t(5));
就不能添加一条记录,不知道我的函数使用的不正确还是怎么回事?
大家帮忙看一下吧。很急我的邮箱是hanzhenhua2008@126.com 。
qq:190018283
|
|