这个问题你很有可能不知道的,不信吗?
下面这个函数是我从我写的组件源代码中COPY过来的,一个字都没少,而且可以正常的生成DLL文件,唯一的问题就是在我测试该组件里的各接口时,不管我怎么调用,都无条件的出现下面的提示性错误:
Unhandled exception in Project1.exe(KERNEL32.DLL):0xE06D7363:Microsoft C++ Exception.
然后我能做的唯一一件事就是,先乖乖的点击确定按钮,这后就进入了VC的Disaassmbly区域了,没办法,不管怎么样在下面的函数里设置断点,也不管用啊,我真的不知道这究竟会是什么错误,望高手或专家们指点指点啊
而且奇怪的是该组件里的所有接口函数都出现上面同一错误,连程序中设置的catch也抓不到啊,我很郁闷呀
STDMETHODIMP CUser::DeleteUserInfo(int x_nType,int x_UID, BSTR *x_Success)
{
try
{
// TODO: Add your implementation code here
if(FAILED(pConn.CreateInstance(__uuidof(Connection))))
{
*x_Success=::SysAllocString(L"Create Instance error when using DeleteUserInfo() function in userinfo.dll!");
return S_OK;
}
// if(FAILED(pConn->Open("Provider=MSDASQL.1;Password=;Persist Security Info=True;User ID=SA;Data Source=EXAM;Initial Catalog=EXAM;","","",-1)))
if (FAILED(pConn->Open("Provider=SQLOLEDB.1; Data Source=WIN2K; User ID=sa; pwd=;Initial Catalog=EXAM;","","",-1)))
{
*x_Success=::SysAllocString(L"Open Connection error when using DeleteUserInfo() function in userinfo.dll!");
return S_OK;
}
CComBSTR m_bstrSQL;
char m_charUID[10];
_itoa(x_UID,m_charUID,10);
//根据不同的用户类型(老师或学生)产生相应的DELETE SQL 语句
switch(x_nType)
{
case 0:
m_bstrSQL.Append("delete STUDENTACCOUNT where SID=");
break;
case 1:
m_bstrSQL.Append("delete TEACHERACCOUNT where TID=");
break;
default:
*x_Success=::SysAllocString(L"type does not exist when using DeleteUserInfo() function in userinfo.dll!");
return S_OK;
}
m_bstrSQL.Append(m_charUID);
_bstr_t m_bstrResult(m_bstrSQL,FALSE);
CComVariant m_varNum;
pConn->Execute(m_bstrResult,&m_varNum,-1);
if(m_varNum.lVal!=1)
{
*x_Success=::SysAllocString(L"delete operation doesn't succeed when using DeleteUserInfo() function in userinfo.dll!");
return S_OK;
}
else
*x_Success=::SysAllocString(L"Delete Successfully!");
pConn->Close();
return S_OK;
}
catch(...)
{
*x_Success=::SysAllocString(L"Other Errors!");
return S_OK;
}
}
郁闷郁闷郁闷郁闷郁闷郁闷郁闷郁闷郁闷郁闷郁闷郁闷郁闷郁闷郁闷郁闷郁闷郁闷郁闷