void CChickensDoc::OnMenuadd()
{
CString sql;
CString curTime,curDate;
SYSTEMTIME sysTime;
int year,month,day,hour,minute,second;
::GetLocalTime(&sysTime);
year=sysTime.wYear;
month=sysTime.wMonth;
day=sysTime.wDay;
hour=sysTime.wHour;
minute=sysTime.wMinute;
second=sysTime.wSecond;
curDate.Format("%d-%d-%d %d:%d:%d",year,month,day,hour,minute,second);
curTime.Format("%d:%d:%d",hour,minute,second);
//当前时间
try
{
CString reVal="";
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);
TRACE("失败");
reVal=reParam->GetValue().bstrVal;
reVal="0"+reVal;
strcpy(id,reVal);
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("添加失败");
}
}
我的添加功能只能执行一次,再添加就失败,应该是存储过程的毛病?谁能看看什么原因啊
--??另外,sql里有没有时间类型啊,只有datetime么??--