I'm porting my C++ (EVC3) application from Sql CE 2.0 to Sql Mobile 3.0
(with OLE DB). To compact a 2.0 database, i used ISSCECompact interface.
But it doesn't exists with the new version. I've only found C#
and VB.Net samples in MSDN ...
Thanks in advance.
Have you had a chance to look at: http://msdn2.microsoft.com/en-us/library/ms174034(en-US,SQL.90).aspx
Thanks,
Laxmi NRO, MSFT, SQL Mobile, Microsoft Corporation
|||#include "ca_merge30.h"
#include <stdio.h>
void ErrorPrint() ;
#define VerifyResult(x) hr=x;\
if(FAILED(hr)) { \
printf("Failed : HR : %x\n",hr); \
printf("at : %d \n",__LINE__); \
ErrorPrint(); \
goto Exit; \
}
#define RELEASE(x) if(NULL!=x)x->Release();
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));
Exit:
RELEASE(pISSCEEngine);
CoUninitialize();
return hr;
}
void ErrorPrint()
{
LPVOID lpMsgBuf;
DWORD dw = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
printf( "Failed with error %d: %ls",
dw, lpMsgBuf);
LocalFree(lpMsgBuf);
}
Hope this helps! Thanks,
Laxmi NRO, MSFT, SQL Mobile, Microsoft Corporation
(Sample By: BalaDutt, MSFT, SQL Mobile, Microsoft Corporation)
|||Many thanks ! It's exactly what i needed !|||Glad that I could help you.
Thanks,
Laxmi Narsimha Rao ORUGANTI, MSFT, SQL Mobile, Microsoft Corporation
|||This helped me as well, thanks. But I also cannot find any 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?
No comments:
Post a Comment