int C51JobWebPost::GetFirstUsefulKey() { int iRet = -1; CAdoConnection adoConn; CAdoRecordSet adoRst; try { if ( !adoConn.IsOpen() ) //如果未连接上服务器 { CString strAppPath = ""; CUserFile::GetInstance()->GetAppPath(strAppPath); if ( !adoConn.ConnectAccess(strAppPath+"machineInfo.mdb","")) { ShowMessage("连接数据库失败"); return -1; } adoRst.SetAdoConnection(&adoConn); adoRst.SetCursorLocation(adUseClient); } CString strSQL; strSQL.Format("select top 1 * from [machine] where datediff('d',lastusetime,now()) > 0 order by [ID] asc"); if(!adoRst.Open(strSQL,adCmdText)) { iRet = -1; ShowMessage("读取键值信息失败"); } else { if (!adoRst.IsEOF()) { adoRst.GetCollect("ID",m_iID); adoRst.GetCollect("machineserial",m_strMac); adoRst.GetCollect("transactionid",m_strTrans); adoRst.GetCollect("verify",m_strVerify); iRet = 0; } else { ShowMessage("当天已经没有可用的键值信息,请调用生成程序"); iRet = -1; } } adoRst.Close(); adoConn.Close(); return iRet; } catch (...) { adoRst.Close(); adoConn.Close(); ShowMessage("读取键值信息异常"); } return -1; }
void CTypeManager::GetAllType(CList<CType,CType> *pLstType) { CAdoRecordSet set; set.SetAdoConnection(m_pConn); set.SetCursorLocation(); set.Open("TypeInfo",adCmdTable); CType type; while(!set.IsEOF()) { set.GetCollect("id",type.nTypeID); set.GetCollect("typeName",type.strTypeName); pLstType->AddTail(type); set.MoveNext(); } }
void CVideoManager::GetVideosByTypeID(long typeID,CList<CVideo,CVideo> *pLstVideo) { CString strSql; strSql.Format("select id,videoName from videoinfo where typeid=%d",typeID); CAdoRecordSet set; set.SetAdoConnection(m_pConn); set.SetCursorLocation(); set.Open(strSql); CVideo v; while(!set.IsEOF()) { set.GetCollect("id",v.nVideoID); set.GetCollect("videoName",v.strVideoName); pLstVideo->AddTail(v); set.MoveNext(); } }
CString CVideoManager::GetVideoPathByID(long videoID) { CString strSql; strSql.Format("select videoPath from videoInfo where id=%d",videoID); CAdoRecordSet set; set.SetAdoConnection(m_pConn); set.SetCursorLocation(); set.Open(strSql); CString strVideoPath=""; if (!set.IsEOF()) { set.GetCollect("videoPath",strVideoPath); } return strVideoPath; }