|
我的程序是这么写的,到open哪儿就打不开了.有人说是路径的问题,可是我看不出来路径有问题啊?哪位大侠帮帮忙吧!
if(FAILED(CoInitializeEx(NULL, COINIT_MULTITHREADED)))
return FALSE;
HRESULT hr;
hr = CLSIDFromProgID(m_ProgID, &m_ClsID);
TCHAR* lpDataSource = new TCHAR[255];
_tcscpy(lpDataSource,_T("Provider = Microsoft.SQLSERVER.OLEDB.CE.2.0;data source =\My Documents\lz.sdf"));
if(FAILED(hr))
{
delete[] lpDataSource;
return FALSE;
}
//-----------------------------
hr = CoCreateInstance(m_ClsID, NULL, CLSCTX_INPROC_SERVER, IID__Connection, (LPVOID*) &m_Conn);
if(FAILED(hr))
{
delete[] lpDataSource;
return FALSE;
}
hr = m_Conn->put_Provider(TEXT("CEDB"));
if(FAILED(hr))
{
delete[] lpDataSource;
return FALSE;
}
hr = m_Conn->Open(TEXT(lpDataSource,TEXT(""),TEXT(""),adOpenUnspecified);
int a = GetLastError();
if(FAILED(hr))
{
delete[] lpDataSource;
return FALSE;
}
//-------------------------------------------------------------
delete[] lpDataSource;
return TRUE;
|
|