ODBC连接数据源的问题

来源:百度知道 编辑:UC知道 时间:2024/06/08 13:31:27
UpdateData(TRUE);
CDatabase m_db;
int m=m_db.Open(_T("学生信息"));
CString str1,str2,str3;
int i=0;
CAset m_set;
m_set.m_pDatabase=&m_db;
CString strSQL;
strSQL.Format("select * from studentgrade sg where sg.courseid in (select sc.couseid from studentcourse sc where sc.coursename='%s' and sg.num='%s')",m_subject,m_num);
//strSQL.Format("select * from studentgrade a where a.courseid in (select couseid from studentcourse b where b.coursename='化学' and a.num='0708001')");

//strSQL.Format("select * from studentgrade where num='%s'",m_num);
int t=m_set.Open(CRecordset::forwardOnly,strSQL,CRecordset::readOnly);
int q=m_set.IsOpen();

while(!m_set.IsEOF())
{
m_ListCtrl.InsertItem(i,m_set.m_num);
m_ListCtrl.SetItemText(i,1,m_set.m_courseid);
str1.Format("%d",m_set.m_score);
m_ListC

先使用一些短小的SQL语句,让m_set执行,看执行情况,我就看你的sql语句错误了
select * from studentgrade sg where num='%s' and sg.courseid in (select sc.couseid from studentcourse sc where sc.coursename='%s' )",m_num,m_subject

m_set.Open(CRecordset::snapshot,strSQL,CRecordset::readOnly);
记录集使用快照