MFC Help

This is a discussion on MFC Help within the Windows Programming forums, part of the Platform Specific Boards category; OK, Im building a database app. I can get the tables to appear in my CDatabase listcontrol. But Im have ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    2

    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
    UpdateData();
    m_Edit_Cost = _T("");
    m_Edit_Count = _T("");
    m_Edit_Desc = _T("");
    m_Edit_ExtendedCost = _T("");
    m_Edit_ID = _T("");
    m_Edit_Name = _T("");
    UpdateData(FALSE);

    }

    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);
    TRY
    {
    UpdateData(TRUE);

    //open the database
    database.Open(NULL,false,false,sDsn);


    //excecute the query
    //create the recordset
    RecsetSec1 rs;
    rs.AddNew();
    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;

    UpdateData(FALSE);






    //close the database
    database.Close();
    }
    CATCH(CDBException, e)
    {
    //error message
    AfxMessageBox("Database error: "+e->m_strError);
    }
    END_CATCH;*/
    }

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

    RecsetSec1 rs(database);
    hth
    -nv

    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21