怎麼用oledb com api使用 ADO 呢? 程序執行不過 pConn->Open(......)
怎麼用oledb com api使用 ADO 呢?
使用以下頭文件,不使用inport 方式
#include "adoid.h"
#include "adoint.h"
1. _ADOConnection 對象打開不成功? 代碼如下:
HRESULT hr = S_OK;
_ADOConnection * pConn= NULL;
CString strtemp;
hr = CoCreateInstance( CLSID_CADOConnection, NULL, CLSCTX_INPROC_SERVER,IID_IADOConnection, (LPVOID *) &pConn );
if( !SUCCEEDED(hr) )
{
::MessageBox( NULL, "創建數據連接對象失敗 !", "用戶驗證", MB_OK );
return;
}
strtemp=L"Provider=SQLOLEDB.1;Data Source=PRCSQL;Initial Catalog=SGSROHS;User ID=sa;" ;
hr=pConn->Open(strtemp.AllocSysString(),NULL,NULL,NULL);
程序執行不過 pConn->Open(......)
出現以下錯誤:
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Error!
Program: E:\lakerworkspace\VCPROJECT\SGSROHS\Debug\SGSROHS.exe
Module:
File: i386\chkesp.c
Line: 42
The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
(Press Retry to debug the application)
---------------------------
中止(A) 重試(R) 略過(I)
---------------------------