Thread: MFC Help

  1. #1
    Registered User
    Join Date
    Apr 2003

    Talking MFC Help

    OK, Im building a database app. I can get the tables to appear in my CDatabase listcontrol. But Im have trouble with my add- a -record function. Heres some code;

    Basically its telling me that RecordsetSec1 is undefined. But this is my recordset class derived from CRecordset. Am I missing adding a header file some where ?
    void CAddDialog1::OnButtClear()
    //Clear the fields here
    m_Edit_Cost = _T("");
    m_Edit_Count = _T("");
    m_Edit_Desc = _T("");
    m_Edit_ExtendedCost = _T("");
    m_Edit_ID = _T("");
    m_Edit_Name = _T("");


    void CAddDialog1::OnButtSaveContinue()
    CDatabase database;
    CString SqlString;
    CString s1_ID, s1_Name, s1_Desc, s1_Count, s1_Cost, s1_ExtendedCost;
    CString sDriver = "MICROSOFT ACCESS DRIVER (*.mdb)";
    CString sDsn;
    CString sFile = "Inventory.mdb";
    //int iRec = 0;

    //build the ODBC connection string
    sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s",sDriv er,sFile);

    //open the database

    //excecute the query
    //create the recordset
    RecsetSec1 rs;
    rs.m_s1_ID == m_Edit_ID;
    rs.m_s1_Name == m_Edit_Name;
    rs.m_s1_Desc == m_Edit_Desc;
    rs.m_s1_Count == m_Edit_Count;
    rs.m_s1_Cost == m_Edit_Cost;
    rs.m_s1_ExtendCost == m_Edit_ExtendedCost;


    //close the database
    CATCH(CDBException, e)
    //error message
    AfxMessageBox("Database error: "+e->m_strError);

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Hannover, Germany
    For starters, let the recordset know on which database it has to operate:

    RecsetSec1 rs(database);

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WIndows programming?
    By hostensteffa in forum Windows Programming
    Replies: 7
    Last Post: 06-07-2002, 08:52 PM
  2. Release MFC Programs & Dynamic MFC DLL :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-18-2002, 06:42 PM
  3. Understanding The Future of MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 04-15-2002, 09:08 PM
  4. Beginning MFC (Prosise) Part III - Now What? :: C++
    By kuphryn in forum C++ Programming
    Replies: 5
    Last Post: 03-03-2002, 05:58 PM
  5. MFC is Challenging :: C++
    By kuphryn in forum C++ Programming
    Replies: 8
    Last Post: 02-05-2002, 12:33 AM