这样一段代码,为什么异常提示是:数据集只读,我并没有改变该数据集的读写操作属性呀,
急!!!!!在线等,问题解决了立刻给分!try
{
if (!rsConfig.IsOpen())
{
rsConfig.Open(CRecordset::dynaset,_T("select * from tbConfig"));
}
else
{
rsConfig.Close();
rsConfig.Open(CRecordset::dynaset,_T("select * from tbConfig"));
}
}
catch(CDBException* e)
{
AfxMessageBox(e->m_strError);
return;
}//////////////////// 添加记录个数 ///////////////////////////////////
try
{
if (rsConfig.CanAppend())//可以不用,这里是刚才检测代码用的,异常中有了
{
rsConfig.AddNew();
rsConfig.m_ThresholdHour = iHour;
rsConfig.m_ThresholdMinute = iMinute;
rsConfig.m_Delta = iDelta;
rsConfig.Update();
return;
}
else
{
MessageBox("记录集只读!","提示",MB_ICONINFORMATION);
return;
}
}
catch(CDBException* e)
{
AfxMessageBox(e->m_strError);
return;
}
急!!!!!在线等,问题解决了立刻给分!try
{
if (!rsConfig.IsOpen())
{
rsConfig.Open(CRecordset::dynaset,_T("select * from tbConfig"));
}
else
{
rsConfig.Close();
rsConfig.Open(CRecordset::dynaset,_T("select * from tbConfig"));
}
}
catch(CDBException* e)
{
AfxMessageBox(e->m_strError);
return;
}//////////////////// 添加记录个数 ///////////////////////////////////
try
{
if (rsConfig.CanAppend())//可以不用,这里是刚才检测代码用的,异常中有了
{
rsConfig.AddNew();
rsConfig.m_ThresholdHour = iHour;
rsConfig.m_ThresholdMinute = iMinute;
rsConfig.m_Delta = iDelta;
rsConfig.Update();
return;
}
else
{
MessageBox("记录集只读!","提示",MB_ICONINFORMATION);
return;
}
}
catch(CDBException* e)
{
AfxMessageBox(e->m_strError);
return;
}
解决方案 »
- 重叠端口socket和普通的socket创建有差异吗?
- C程序中模拟提交按钮失效
- 软件测试说明是什么
- delete 出错
- 请问:如何设置字体
- 信道.我用SOCKET做了客户端/服务端,需要用信道模拟,但不会做信道.希望各位大侠能帮我啊!
- [matlab]builder for COM 出现 The chosen compiler does not support building COM objects
- CListctrl表头拖曳,交换列位置,如何获得拖曳交换后的位置
- CDAILOG的问题(问题)
- 为什么我在对话条中加入编辑控件时,给该控件添加变量会影响对话条上的工具条呢?(在线等待)
- PPP Terminate-Request Frame 关于协议的问题 100分
- 客户程序访问DLL中全局变量问题
即:m_nDefaultType = dynaset;
strSQL="select * from catalog order by cataid";
pRs->Open(_bstr_t(strSQL),vtMissing,adOpenDynamic,adLockBatchOptimistic,adCmdText);看到没?
adOpenDynamic,adLockBatchOptimistic
查查这两个参数位置的一些参数用法附:1.stdafx.h中加入
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","adoEOF")
2。app文件的InitInstance中加入
if(S_OK!=OleInitialize(NULL))
{
AfxMessageBox("初始化COM组件库错误");
}
下面就是数据库操作
_ConnectionPtr pConn;
_RecordsetPtr pRs;
CString strSQL;
pConn.CreateInstance(__uuidof(Connection));
pConn->CursorLocation=adUseClient;
strSQL="Provider=SQLOLEDB;Server=Gooyan;DataBase=SkillsBox;UID=sa;PWD=aaaaaaaa";
pConn->Open(_bstr_t(strSQL),"","",-1);
pRs.CreateInstance(__uuidof(Recordset));
pRs->CursorLocation=adUseClient;
pRs->PutActiveConnection(pConn.GetInterfacePtr());
pRs1.CreateInstance(__uuidof(Recordset));
pRs1->CursorLocation=adUseClient;
pRs1->PutActiveConnection(pConn.GetInterfacePtr()); strSQL="select * from catalog order by cataid";
pRs->Open(_bstr_t(strSQL),vtMissing,adOpenDynamic,adLockBatchOptimistic,adCmdText);
比如我在其他函数中OPEN该表了,但我并没有调用CLOSE,
这样是不是不会影响到现在的操作呢?麻烦了