DAO migrating from VC6 to VC7 using MFC - Programmer

This is a discussion on DAO migrating from VC6 to VC7 using MFC - Programmer ; My below functions works in VC6 fine but not in VC7. It's simple MFC database code. ------------------------------------------------------ void CDbfileDlg::OnButton1() { // TODO: Add your control notification handler code here AfxMessageBox("hi file"); CDaoTableDef tableDef(&dbMdb) ; CDaoTableDef tableDef1(&dbMdb) ; CDaoTableDef tableDefop(&dbMdb) ; ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: DAO migrating from VC6 to VC7 using MFC

  1. DAO migrating from VC6 to VC7 using MFC

    My below functions works in VC6 fine but not in VC7.
    It's simple MFC database code.
    ------------------------------------------------------
    void CDbfileDlg::OnButton1()
    {
    // TODO: Add your control notification handler code here
    AfxMessageBox("hi file");
    CDaoTableDef tableDef(&dbMdb) ;
    CDaoTableDef tableDef1(&dbMdb) ;
    CDaoTableDef tableDefop(&dbMdb) ;
    //CDaoTableDef tableDefop(&dbMdb) ;
    CDaoTableDef tableDefeop(&dbMdb) ;
    CDaoTableDef tableDefflags(&dbMdb) ;
    CDaoTableDef tableDefflagset(&dbMdb) ;


    CDaoIndexInfo idx;
    CDaoIndexFieldInfo fld;

    dbMdb.Create("c:\\rrrtest2.mdb") ;

    /////// casefile

    tableDef.Create("Casename") ;
    tableDef.CreateField(_T("CaseID"),dbLong, 4, dbAutoIncrField);

    idx.m_strName = _T("PrimaryKey"); // Primary

    idx.m_pFieldInfos = &fld; // Primary

    idx.m_nFields = 1; // Primary

    idx.m_bPrimary = TRUE; // Secondary

    idx.m_bUnique = TRUE; // Secondary

    idx.m_bClustered = FALSE; // Secondary

    idx.m_bIgnoreNulls = FALSE; // Secondary

    idx.m_bRequired = TRUE; // Secondary

    idx.m_bForeign = FALSE; // Secondary

    idx.m_lDistinctCount = 5; // All - returned, not set!

    fld.m_strName = _T("CaseID"); // Key field

    fld.m_bDescending = FALSE; // Ascending






    tableDef.CreateIndex(idx);
    tableDef.CreateField("CaseDescription",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDef.Append() ;
    tableDef.Close() ;

    ///////Input table

    tableDef1.Create("Input");

    CDaoIndexInfo idx1;
    CDaoIndexFieldInfo fld1;
    CDaoIndexInfo idx2;
    CDaoIndexFieldInfo fld2;


    tableDef1.CreateField(_T("InputID"),dbLong, 4, dbAutoIncrField);
    tableDef1.CreateField(_T("caseID"),dbLong, 4, dbUpdatableField
    |dbVariableField);

    idx1.m_strName = _T("PrimaryKey"); // Primary

    idx1.m_pFieldInfos = &fld1; // Primary

    idx1.m_nFields = 1; // Primary

    idx1.m_bPrimary = TRUE; // Secondary

    idx1.m_bUnique = TRUE; // Secondary

    idx1.m_bClustered = FALSE; // Secondary

    idx1.m_bIgnoreNulls = FALSE; // Secondary

    idx1.m_bRequired = TRUE; // Secondary

    idx1.m_bForeign = FALSE; // Secondary

    idx1.m_lDistinctCount = 5; // All - returned, not set!

    fld1.m_strName = _T("InputID"); // Key field

    fld1.m_bDescending = FALSE; // Ascending


    tableDef1.CreateIndex(idx1);
    tableDef1.CreateField("Country",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDef1.CreateField("Province",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDef1.CreateField("ProvinceOfficial",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDef1.CreateField("City",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDef1.CreateField("CityOfficial",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDef1.CreateField("Street",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDef1.CreateField("StreetMain",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDef1.CreateField("Premises",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDef1.CreateField("POBox",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDef1.CreateField("PS_Cedex",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDef1.CreateField("Postcode",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDef1.CreateField("LargeUser",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDef1.CreateField("LargeUserMain",dbText,255,dbUpdatableField
    |dbVariableField) ;

    tableDef1.Append() ;
    tableDef1.Close() ;

    ///////output table
    tableDefop.Create("Output");
    tableDefop.CreateField(_T("ResultRowNumber"),dbLong, 4,
    dbAutoIncrField);
    tableDefop.CreateField(_T("InputID"),dbLong, 4, dbUpdatableField
    |dbVariableField);
    CDaoIndexInfo idxop;
    CDaoIndexFieldInfo fldop;

    idxop.m_strName = _T("PrimaryKey"); // Primary

    idxop.m_pFieldInfos = &fldop; // Primary

    idxop.m_nFields = 1; // Primary

    idxop.m_bPrimary = TRUE; // Secondary

    idxop.m_bUnique = TRUE; // Secondary

    idxop.m_bClustered = FALSE; // Secondary

    idxop.m_bIgnoreNulls = FALSE; // Secondary

    idxop.m_bRequired = TRUE; // Secondary

    idxop.m_bForeign = FALSE; // Secondary

    idxop.m_lDistinctCount = 5; // All - returned, not set!

    fldop.m_strName = _T("ResultRowNumber"); // Key field

    fldop.m_bDescending = FALSE; // Ascending


    tableDefop.CreateIndex(idxop);


    tableDefop.CreateField("Country",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("Province",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("ProvinceOfficial",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("City",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("CityOfficial",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("Street",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("StreetMain",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("Premises",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("POBox",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("PS_Cedex",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("Postcode",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("LargeUser",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("LargeUserMain",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("FormatAddress",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("FormatCountryLine",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("FormatCityLine",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("FormatStreetLine",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("FormatPOBoxLine",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("FormatLine1",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("FormatLine2",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("FormatLine3",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("FormatLine4",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("FormatLine5",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("FormatLine6",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("FormatLine7",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefop.CreateField("FormatLine8",dbText,255,dbUpdatableField
    |dbVariableField) ;

    tableDefop.Append() ;
    tableDefop.Close() ;

    ///////Expecteoutput table

    tableDefeop.Create("ExpectedOutput");
    tableDefeop.CreateField(_T("ResultRowNumber"),dbLong, 4,
    dbAutoIncrField);
    tableDefeop.CreateField(_T("InputID"),dbLong, 4,
    dbUpdatableField |dbVariableField);
    CDaoIndexInfo idxeop;
    CDaoIndexFieldInfo fldeop;

    idxeop.m_strName = _T("PrimaryKey"); // Primary

    idxeop.m_pFieldInfos = &fldeop; // Primary

    idxeop.m_nFields = 1; // Primary

    idxeop.m_bPrimary = TRUE; // Secondary

    idxeop.m_bUnique = TRUE; // Secondary

    idxeop.m_bClustered = FALSE; // Secondary

    idxeop.m_bIgnoreNulls = FALSE; // Secondary

    idxeop.m_bRequired = TRUE; // Secondary

    idxeop.m_bForeign = FALSE; // Secondary

    idxeop.m_lDistinctCount = 5; // All - returned, not set!

    fldeop.m_strName = _T("ResultRowNumber"); // Key field

    fldeop.m_bDescending = FALSE; // Ascending


    tableDefeop.CreateIndex(idxeop);


    tableDefeop.CreateField("Country",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("Province",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("ProvinceOfficial",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("City",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("CityOfficial",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("Street",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("StreetMain",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("Premises",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("POBox",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("PS_Cedex",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("Postcode",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("LargeUser",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("LargeUserMain",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("FormatAddress",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("FormatCountryLine",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("FormatCityLine",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("FormatStreetLine",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("FormatPOBoxLine",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("FormatLine1",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("FormatLine2",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("FormatLine3",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("FormatLine4",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("FormatLine5",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("FormatLine6",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("FormatLine7",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefeop.CreateField("FormatLine8",dbText,255,dbUpdatableField
    |dbVariableField) ;

    tableDefeop.Append() ;
    tableDefeop.Close() ;

    //flags

    tableDefflags.Create("flags") ;
    tableDefflags.CreateField(_T("FlagID"),dbLong, 4,
    dbAutoIncrField);
    CDaoIndexInfo idxflags;
    CDaoIndexFieldInfo fldflags;


    idxflags.m_strName = _T("PrimaryKey"); // Primary

    idxflags.m_pFieldInfos = &fldflags; // Primary

    idxflags.m_nFields = 1; // Primary

    idxflags.m_bPrimary = TRUE; // Secondary

    idxflags.m_bUnique = TRUE; // Secondary

    idxflags.m_bClustered = FALSE; // Secondary

    idxflags.m_bIgnoreNulls = FALSE; // Secondary

    idxflags.m_bRequired = TRUE; // Secondary

    idxflags.m_bForeign = FALSE; // Secondary

    idxflags.m_lDistinctCount = 5; // All - returned, not set!

    fldflags.m_strName = _T("FlagID"); // Key field

    fldflags.m_bDescending = FALSE; // Ascending

    tableDefflags.CreateIndex(idxflags);
    tableDefflags.CreateField("flagname",dbText,255,dbUpdatableField
    |dbVariableField) ;
    tableDefflags.Append() ;
    tableDefflags.Close() ;

    /////flagsetting table


    tableDefflagset.Create("FlagSetting") ;
    tableDefflagset.CreateField(_T("FlagID"),dbLong, 4,
    dbAutoIncrField);
    tableDefflagset.CreateField(_T("InputID"),dbLong, 4,
    dbUpdatableField |dbVariableField);
    CDaoIndexInfo idxflagset;
    CDaoIndexFieldInfo fldflagset;


    idxflagset.m_strName = _T("PrimaryKey"); // Primary

    idxflagset.m_pFieldInfos = &fldflagset; // Primary

    idxflagset.m_nFields = 1; // Primary

    idxflagset.m_bPrimary = TRUE; // Secondary

    idxflagset.m_bUnique = TRUE; // Secondary

    idxflagset.m_bClustered = FALSE; // Secondary

    idxflagset.m_bIgnoreNulls = FALSE; // Secondary

    idxflagset.m_bRequired = TRUE; // Secondary

    idxflagset.m_bForeign = FALSE; // Secondary

    idxflagset.m_lDistinctCount = 5; // All - returned, not set!

    fldflagset.m_strName = _T("FlagID"); // Key field

    fldflagset.m_bDescending = FALSE; // Ascending

    tableDefflagset.CreateIndex(idxflagset);
    tableDefflagset.CreateField(_T("FlagValue"),dbLong, 4,
    dbUpdatableField |dbVariableField);
    tableDefflagset.CreateField(_T("FlagSetHow"),dbLong, 4,
    dbUpdatableField |dbVariableField);
    tableDefflagset.Append() ;
    tableDefflagset.Close() ;


    dbMdb.Close();


    }

  2. Re: DAO migrating from VC6 to VC7 using MFC

    DAO is being depreciated and will not be supported in the future. Your code
    should compile and work, but they make it difficult to write new DAO code.
    You should port to either ODBC (CDatabase/CRecordset), or to ADO.


    --
    -------------------------------------------------------------------------
    Free software - Baxter Codeworks www.baxcode.com
    -------------------------------------------------------------------------


    "afxuser" wrote in message
    news:3d30cf36.0401060119.53b536dc@posting.google.c om...
    > My below functions works in VC6 fine but not in VC7.
    > It's simple MFC database code.





+ Reply to Thread