MFC 关于一段代码,看不懂,求大神?
本帖最后由 VisualEleven 于 2012-08-23 18:39:46 编辑 一个Button响应函数里的代码,不知道是什么意思。。里面booking是CDaoDatabase类的一个对象
CString sPath;
GetModuleFileName(NULL,sPath.GetBufferSetLength (MAX_PATH+1),MAX_PATH);
sPath.ReleaseBuffer ();
int nPos;
nPos=sPath.ReverseFind ('\\');
sPath=sPath.Left (nPos);
CString lpszFile = sPath + "\\booking.mdb";
booking.Open(lpszFile);
CString sql;
sql.Format("INSERT INTO booking (room_row,seat,name,room,data) VALUES ('%s','%s','%s','%s','%s')",m_row,m_number,m_name,m_room,m_data);
booking.Execute(sql);
//下面是获取程序当前执行路径
CString sPath;
GetModuleFileName(NULL,sPath.GetBufferSetLength (MAX_PATH+1),MAX_PATH);
sPath.ReleaseBuffer ();
int nPos;
nPos=sPath.ReverseFind ('\\');
sPath=sPath.Left (nPos);
//获取文件booking的绝对路径
CString lpszFile = sPath + "\\booking.mdb";
booking.Open(lpszFile);
//执行插入语句
CString sql;
sql.Format("INSERT INTO booking (room_row,seat,name,room,data) VALUES ('%s','%s','%s','%s','%s')",m_row,m_number,m_name,m_room,m_data);
booking.Execute(sql);