Friday, March 30, 2012

How to Verify a DB via OLEDB?

I cannot find any OLE DB reference material for how to perform a "Verify" DB as advertised in the Documentation for SQL Server Mobile Edition.

The docs have a sample in C#, but nothing for OLD DB in C++.

Does anyone know how to do this?

Unfortunately it's not exposed through OLEDB. You can do other things like Repair, UpgradeDatabase etc through ISSCEEngine. Sample code would be

extern "C" int __cdecl wmain(){

HRESULT hr = NOERROR;
ISSCEEngine *pISSCEEngine = NULL;
VerifyResult(CoInitialize(NULL));
VerifyResult(CoCreateInstance(CLSID_Engine, NULL, CLSCTX_INPROC_SERVER,
IID_ISSCEEngine, (void**)&pISSCEEngine));

WCHAR *wszSrc=L"Data Source = src.sdf";
WCHAR *wszDst=L"Data Source = dst.sdf";
VerifyResult(pISSCEEngine->CompactDatabase(wszSrc, wszDst));

WCHAR *wszNew=L"Data Source = new.sdf";
VerifyResult(pISSCEEngine->CreateDatabase(wszNew));


Exit:
RELEASE(pISSCEEngine);
CoUninitialize();
return hr;
}

Thanks

Raja

P.S: Please mark the question as answered if your satisfied with the answer.

No comments:

Post a Comment