使用MFC CRecordset类访问SQL Server7,为何不能添加新记录?
我的代码:
CDatabase db;
CString strConnect(szConnectString);
strConnect += "DSN=NBM;";
if (!db.OpenEx(strConnect, CDatabase::noOdbcDialog))
AfxMessageBox("Can not open database");
else
{
BOOL b = db.CanUpdate();
CLogSet cs(&db);
cs.Open(CRecordset::dynaset, NULL, CRecordset::appendOnly);
BOOL c = cs.CanAppend();
cs.AddNew();
cs.m_ComputerIP = "192.168.0.1";
cs.Update();
cs.Close();
db.Close();
}
为何记录集总是只读的?
请高手指教