void CChickensDoc::OnMenuadd()
{
CString sql;
CString curTime,curDate;
SYSTEMTIME sysTime;
::GetLocalTime(&sysTime);
curDate.Format("%d-%d-%d %d:%d:%d",sysTime.wYear,sysTime.wMonth,sysTime.wDay,
sysTime.wHour,sysTime.wMinute,sysTime.wSecond);
curTime.Format("%d:%d:%d",sysTime.wHour,sysTime.wMinute,sysTime.wSecond);
//当前时间
try
{
CString reIdVal="";
char id[8];
_ParameterPtr reParam;
reParam=m_com->CreateParameter(_bstr_t("Return"),adVarChar,adParamReturnValue,8);
m_com->Parameters->Append(reParam);
m_com->ActiveConnection = m_con;
m_com->CommandType = adCmdStoredProc;
m_com->CommandText = "newOrderNum";
m_com->Execute(NULL,NULL,adCmdStoredProc);
reIdVal=reParam->GetValue().bstrVal;
reIdVal="0"+reIdVal;
strcpy(id,reIdVal);
sql.Format("insert into checking(id,checktime,musttime,starttime) values('%s','%s','%s','%s')",
id,curDate,curTime,curTime);
m_com->ActiveConnection=m_con;
m_com->CommandText = (_bstr_t)sql;
m_com->Execute(NULL, NULL, adCmdText);
AfxMessageBox("入库");
UpdateAllViews(NULL);
}
catch(_com_error e)
{
AfxMessageBox(e.Error());
}
}
这是我添加的所有代码,版主能看看哪里有不妥的地方不,会不会又是什么内存溢出的