精通
英语
和
开源
,
擅长
开发
与
培训
,
胸怀四海
第一信赖
锐英源开源心得,禁止任何转载,有技术问题请找锐英源孙老师QQ396806883,微信ryysoft。
int GetAutoID()
{
COleVariant ColeArry;
CString sSQL;
int iID=-1;
sSQL.Format("SELECT @@IDENTITY AS 'LID'");
try
{
HRESULT ht;
_RecordsetPtr RecordVip;
ht=RecordVip.CreateInstance(__uuidof(Recordset));
if (FAILED(ht))
{
AfxMessageBox("不能初始化一个记录集实例");
return -1;
}
RecordVip->CursorLocation=adUseClient;
RecordVip->Open(sSQL.AllocSysString(),(IDispatch *)gpConn,adOpenDynamic
,adLockOptimistic,adCmdText);
ColeArry=RecordVip->Fields->GetItem("LID")->Value;
iID=ColeArry.cyVal.int64;
RecordVip->Close();
RecordVip.Release();
}
catch (CException* e)
{
char cError[255];
e->GetErrorMessage(cError,255);
sprintf(cError,"%s",cError);
AfxMessageBox(cError);
return iID;
}
return iID;
}