Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Error "Recordset is read-only" ???

Error "Recordset is read-only" ???

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++announcement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _skidrow_vn_
    wrote on last edited by
    #1

    I have 2 tables in mydatabase "Account" and "Employee" I want to edit my record but there is a Error messagebox always show ----------------------------- "Recordset is read-only" ----------------------------- How can I fix it? thanks // I want to Edit password,permission of employee // who have ID="John" >>>>>> Account.ID="John" then..... // Account.Pass="John1" => edit to new password => Account.Pass="John2" // Employee.Permission=2 => edit to new permission => Employee.Permission=3 // QLBH2Set.cpp : implementation of the CAccountSet class // IMPLEMENT_DYNAMIC(CAccountSet, CRecordset) CAccountSet::CAccountSet(CDatabase* pdb) : CRecordset(pdb) { m_ID = _T(""); m_Pass = _T(""); m_Employee_ID = _T(""); m_Permission = 0; m_nFields = 4; m_nDefaultType = dynaset;//snapshot; } CString CAccountSet::GetDefaultConnect() { return _T("ODBC;DRIVER=Microsoft Access Driver (*.mdb);DBQ=C:\\MyDB.mdb"); } CString CAccountSet::GetDefaultSQL() { return _T([Account],[Employee]); } void CAccountSet::DoFieldExchange(CFieldExchange* pFX) { pFX->SetFieldType(CFieldExchange::outputColumn); RFX_Text(pFX, _T("[ID]"), m_ID); RFX_Text(pFX, _T("[Pass]"), m_Pass); RFX_Long(pFX, _T("[Permission]"), m_Permission); RFX_Text(pFX, _T("[Employee_ID]"), m_Employee_ID); } ///////////////////////////////////////////////////////////////////////////// // CChangePassword dialog class CChangePassword : public CDialog { // Construction public: CChangePassword(CWnd* pParent = NULL); // standard constructor CAccountSet m_Set; ..... } ///////////////////////////////////////////////////////////////////////////// // CChangePassword message handlers void CChangePassword::OnOK() { ....... m_Set.m_strFilter = "Account.ID = Employee.Employee_ID"; m_Set.Open(CRecordset::dynaset, _T( "SELECT ALL Account.ID,Account.Pass,Employee.Permission FROM Account INNER JOIN Employee ON Account.ID=Employee.Empoyee_ID" ), CRecordset::executeDirect); // I want to Edit password,permission of employee // who have ID="John" >>>>>> Account.ID="John" // Account.Pass="John1" => edit to new password => Account.Pass="John2" // Employee.Permission=2 => edit to new permission => Employee.Permission=3 m_Set.Edit(); m_Set.m_Pass = strNewPass; m_Set.Update( ); m_Set.Requery (); m_Set.Close(); ..... }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups