首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

odbc连接数据库不能更新(recordset is read-only),该怎么处理

2013-01-04 
odbc连接数据库不能更新(recordset is read-only)RT代码如下:void CChengView::OnButtonTj() {// TODO: Ad

odbc连接数据库不能更新(recordset is read-only)
RT
代码如下:
void CChengView::OnButtonTj() 
{
// TODO: Add your control notification handler code here
cc dlg ;
if(dlg.DoModal()==IDOK)
{
int flag=0;
m_pSet->MoveFirst();
UpdateData(TRUE);
while(!m_pSet->IsEOF())
{
if(dlg.m_SNo==m_pSet->m_SNo)
{
flag=1;
MessageBox("该学生信息已存在","学生管理系统",0);
break;
}
m_pSet->MoveNext();
}
if(flag==0)
{
             m_pSet->AddNew();
 m_pSet->m_SNo=dlg.m_SNo;
 m_pSet->m_SN=dlg.m_SN;
 m_pSet->m_Sex=dlg.m_Sex;
 m_pSet->m_Age=dlg.m_Age;
 m_pSet->m_Dept=dlg.m_Dept;
 m_pSet->Update();//新纪录写入数据库的数据表
 m_pSet->Requery();//刷新纪录
 MessageBox("添加成功","学生管理系统",0);
}
}
}
添加数据时,出现recordset is read-only;
[解决办法]
把数据库连接的代码贴出来吧

连接时用要用写的方式
[解决办法]
肯定你Open的方法有问题,楼主上代码看看吧。

热点排行