Database connection to MS Access & MS Foxpro - Programmer

This is a discussion on Database connection to MS Access & MS Foxpro - Programmer ; Hi, When we select new project ,can "MFC AppWizard(exe)" make connection to database ? or only "database project" can make connection to database ? How do i make connection to database(MS Access/Foxpro) and perform sql using MFC Appwizard(exe) with ODBC ...

+ Reply to Thread
Results 1 to 10 of 10

Thread: Database connection to MS Access & MS Foxpro

  1. Database connection to MS Access & MS Foxpro

    Hi,

    When we select new project ,can "MFC AppWizard(exe)" make connection
    to database ? or only "database project" can make connection to
    database ?

    How do i make connection to database(MS Access/Foxpro) and perform sql
    using MFC Appwizard(exe) with ODBC --CDatabase?
    Any sample code ?
    Thanks.

  2. Re: Database connection to MS Access & MS Foxpro

    CBTan wrote:

    > Hi,
    >
    > When we select new project ,can "MFC AppWizard(exe)" make connection
    > to database ? or only "database project" can make connection to
    > database ?
    >
    > How do i make connection to database(MS Access/Foxpro) and perform sql
    > using MFC Appwizard(exe) with ODBC --CDatabase?
    > Any sample code ?
    > Thanks.


    Yes, an MFC application can connect to a database. To use ODBC you must
    first define a DSN in the ODBC manager (in control panel).

    See the ENROLL tutorial and program in the VC help.

    --
    Scott McPhillips [VC++ MVP]


  3. Re: Database connection to MS Access & MS Foxpro

    You can create recordsets with classwizard.
    use CRecordset for ODBC or CDoaRecordset for DAO as base class,
    connect to the database, choice the table and update the fields.
    Read also the book: Visual C++ 6 Database programming tutorial, Wendy
    Sarrett

    Theo Buys

    CBTan wrote in message
    news:5cbd4cb8.0312150134.38bb4a89@posting.google.c om...
    > Hi,
    >
    > When we select new project ,can "MFC AppWizard(exe)" make connection
    > to database ? or only "database project" can make connection to
    > database ?
    >
    > How do i make connection to database(MS Access/Foxpro) and perform sql
    > using MFC Appwizard(exe) with ODBC --CDatabase?
    > Any sample code ?
    > Thanks.




  4. Re: Database connection to MS Access & MS Foxpro

    DAO has been depreciated. MS wants you to move to ADO. Not too hard to
    write wrapper classes to provide the same functionality as
    CDaoDatabase/CDaoRecorset (etc).


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


    "Theo Buys" wrote in message
    news:4027b973$0$1413$19deed1b@news.inter.NL.net...
    > You can create recordsets with classwizard.
    > use CRecordset for ODBC or CDoaRecordset for DAO as base class,
    > connect to the database, choice the table and update the fields.
    > Read also the book: Visual C++ 6 Database programming tutorial, Wendy
    > Sarrett
    >
    > Theo Buys
    >
    > CBTan wrote in message
    > news:5cbd4cb8.0312150134.38bb4a89@posting.google.c om...
    > > Hi,
    > >
    > > When we select new project ,can "MFC AppWizard(exe)" make connection
    > > to database ? or only "database project" can make connection to
    > > database ?
    > >
    > > How do i make connection to database(MS Access/Foxpro) and perform sql
    > > using MFC Appwizard(exe) with ODBC --CDatabase?
    > > Any sample code ?
    > > Thanks.

    >
    >




  5. Re: Database connection to MS Access & MS Foxpro

    Not too hard? How do you create classes that the classwizard can pickup and
    can update the records in your recordset when your database layout is
    changed?


    Baxter wrote in message
    news:102ffi7t6s1b4b1@corp.supernews.com...
    > DAO has been depreciated. MS wants you to move to ADO. Not too hard to
    > write wrapper classes to provide the same functionality as
    > CDaoDatabase/CDaoRecorset (etc).
    >
    >
    > --
    > -------------------------------------------------------------------------
    > Free software - Baxter Codeworks www.baxcode.com
    > -------------------------------------------------------------------------
    >
    >
    > "Theo Buys" wrote in message
    > news:4027b973$0$1413$19deed1b@news.inter.NL.net...
    > > You can create recordsets with classwizard.
    > > use CRecordset for ODBC or CDoaRecordset for DAO as base class,
    > > connect to the database, choice the table and update the fields.
    > > Read also the book: Visual C++ 6 Database programming tutorial, Wendy
    > > Sarrett
    > >
    > > Theo Buys
    > >
    > > CBTan wrote in message
    > > news:5cbd4cb8.0312150134.38bb4a89@posting.google.c om...
    > > > Hi,
    > > >
    > > > When we select new project ,can "MFC AppWizard(exe)" make connection
    > > > to database ? or only "database project" can make connection to
    > > > database ?
    > > >
    > > > How do i make connection to database(MS Access/Foxpro) and perform sql
    > > > using MFC Appwizard(exe) with ODBC --CDatabase?
    > > > Any sample code ?
    > > > Thanks.

    > >
    > >

    >
    >




  6. Re: Database connection to MS Access & MS Foxpro

    I never had much luck with the ClassWizard *changing* a recordset class once
    it was generated. Any changes had to be hand done, or you had to delete and
    regenerate the entire class.

    I'm finding that direct field access is more practical - changes have less
    impact on your code. Something like:
    if (rsTable1.GetIntValue(_T("Field1")) == 1) {
    // do something

    In short, I wrapped the ADO so that I could access the values either
    individually, or as members of a class. I'm finding that copying all the
    values into current memory as CDaoRecordset and CRecordset do is
    unnecessary. If I add a field/column, I don't have to touch existing code
    (except for possible init of a new record)

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


    "Theo Buys" wrote in message
    news:4029e8fd$0$1414$19deed1b@news.inter.NL.net...
    > Not too hard? How do you create classes that the classwizard can pickup

    and
    > can update the records in your recordset when your database layout is
    > changed?
    >
    >
    > Baxter wrote in message
    > news:102ffi7t6s1b4b1@corp.supernews.com...
    > > DAO has been depreciated. MS wants you to move to ADO. Not too hard to
    > > write wrapper classes to provide the same functionality as
    > > CDaoDatabase/CDaoRecorset (etc).
    > >
    > >
    > > "Theo Buys" wrote in message
    > > news:4027b973$0$1413$19deed1b@news.inter.NL.net...
    > > > You can create recordsets with classwizard.
    > > > use CRecordset for ODBC or CDoaRecordset for DAO as base class,
    > > > connect to the database, choice the table and update the fields.
    > > > Read also the book: Visual C++ 6 Database programming tutorial, Wendy
    > > > Sarrett
    > > >
    > > > Theo Buys
    > > >
    > > > CBTan wrote in message
    > > > news:5cbd4cb8.0312150134.38bb4a89@posting.google.c om...
    > > > > Hi,
    > > > >
    > > > > When we select new project ,can "MFC AppWizard(exe)" make connection
    > > > > to database ? or only "database project" can make connection to
    > > > > database ?
    > > > >
    > > > > How do i make connection to database(MS Access/Foxpro) and perform

    sql
    > > > > using MFC Appwizard(exe) with ODBC --CDatabase?
    > > > > Any sample code ?
    > > > > Thanks.
    > > >
    > > >

    > >
    > >

    >
    >




  7. Re: Database connection to MS Access & MS Foxpro

    Can your ADO wrapper classes replace my CDaoRecordset-s without lot of
    recoding?
    I have a lot of old projects (Dao and ODBC) here waiting for an update and
    included a derived recordset which can randomize the data access without
    redundancy.



    Baxter wrote in message
    news:102kt0l271ed5b3@corp.supernews.com...
    > I never had much luck with the ClassWizard *changing* a recordset class

    once
    > it was generated. Any changes had to be hand done, or you had to delete

    and
    > regenerate the entire class.
    >
    > I'm finding that direct field access is more practical - changes have less
    > impact on your code. Something like:
    > if (rsTable1.GetIntValue(_T("Field1")) == 1) {
    > // do something
    >
    > In short, I wrapped the ADO so that I could access the values either
    > individually, or as members of a class. I'm finding that copying all the
    > values into current memory as CDaoRecordset and CRecordset do is
    > unnecessary. If I add a field/column, I don't have to touch existing code
    > (except for possible init of a new record)
    >
    > --
    > -------------------------------------------------------------------------
    > Free software - Baxter Codeworks www.baxcode.com
    > -------------------------------------------------------------------------
    >
    >
    > "Theo Buys" wrote in message
    > news:4029e8fd$0$1414$19deed1b@news.inter.NL.net...
    > > Not too hard? How do you create classes that the classwizard can pickup

    > and
    > > can update the records in your recordset when your database layout is
    > > changed?
    > >
    > >
    > > Baxter wrote in message
    > > news:102ffi7t6s1b4b1@corp.supernews.com...
    > > > DAO has been depreciated. MS wants you to move to ADO. Not too hard

    to
    > > > write wrapper classes to provide the same functionality as
    > > > CDaoDatabase/CDaoRecorset (etc).
    > > >
    > > >
    > > > "Theo Buys" wrote in message
    > > > news:4027b973$0$1413$19deed1b@news.inter.NL.net...
    > > > > You can create recordsets with classwizard.
    > > > > use CRecordset for ODBC or CDoaRecordset for DAO as base class,
    > > > > connect to the database, choice the table and update the fields.
    > > > > Read also the book: Visual C++ 6 Database programming tutorial,

    Wendy
    > > > > Sarrett
    > > > >
    > > > > Theo Buys
    > > > >
    > > > > CBTan wrote in message
    > > > > news:5cbd4cb8.0312150134.38bb4a89@posting.google.c om...
    > > > > > Hi,
    > > > > >
    > > > > > When we select new project ,can "MFC AppWizard(exe)" make

    connection
    > > > > > to database ? or only "database project" can make connection to
    > > > > > database ?
    > > > > >
    > > > > > How do i make connection to database(MS Access/Foxpro) and perform

    > sql
    > > > > > using MFC Appwizard(exe) with ODBC --CDatabase?
    > > > > > Any sample code ?
    > > > > > Thanks.
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >




  8. Re: Database connection to MS Access & MS Foxpro

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


    "Theo Buys" wrote in message
    news:402b8ed6$0$280$19deed1b@news.inter.NL.net...
    > Can your ADO wrapper classes replace my CDaoRecordset-s without lot of
    > recoding?


    Yes, you *could* do it like that. I've not finished that part (it would be
    just a data exchage function). In researching this issue (like at Code Guru
    and Code Project), I came across a program for generating your derived
    classes from your database. I found the non-derived access to be more
    convenient - do note that this method is more like VB's method.

    > I have a lot of old projects (Dao and ODBC) here waiting for an update and


    Yep.

    > included a derived recordset which can randomize the data access without
    > redundancy.


    Whatever that means.

    >
    >
    >
    > Baxter wrote in message
    > news:102kt0l271ed5b3@corp.supernews.com...
    > > I never had much luck with the ClassWizard *changing* a recordset class

    > once
    > > it was generated. Any changes had to be hand done, or you had to delete

    > and
    > > regenerate the entire class.
    > >
    > > I'm finding that direct field access is more practical - changes have

    less
    > > impact on your code. Something like:
    > > if (rsTable1.GetIntValue(_T("Field1")) == 1) {
    > > // do something
    > >
    > > In short, I wrapped the ADO so that I could access the values either
    > > individually, or as members of a class. I'm finding that copying all

    the
    > > values into current memory as CDaoRecordset and CRecordset do is
    > > unnecessary. If I add a field/column, I don't have to touch existing

    code
    > > (except for possible init of a new record)
    > >





  9. Re: Database connection to MS Access & MS Foxpro

    When working with MFC CDao classes in seperate worker threads I had a
    problem with the COleVariant types which generate an Access Violation
    Exception. In my derived classes I have made work-arounds so that the
    COleVariant is not used.

    Is ADO multi-thread save, or do I get the same problem?

    P.S.: I mean with "randomize the data access without redundancy" that I can
    walk through the selected records in a random order while I access each
    record ones.

    Theo


    Baxter wrote in message
    news:102ncu3sev8v2c5@corp.supernews.com...
    > --
    > -------------------------------------------------------------------------
    > Free software - Baxter Codeworks www.baxcode.com
    > -------------------------------------------------------------------------
    >
    >
    > "Theo Buys" wrote in message
    > news:402b8ed6$0$280$19deed1b@news.inter.NL.net...
    > > Can your ADO wrapper classes replace my CDaoRecordset-s without lot of
    > > recoding?

    >
    > Yes, you *could* do it like that. I've not finished that part (it would

    be
    > just a data exchage function). In researching this issue (like at Code

    Guru
    > and Code Project), I came across a program for generating your derived
    > classes from your database. I found the non-derived access to be more
    > convenient - do note that this method is more like VB's method.
    >
    > > I have a lot of old projects (Dao and ODBC) here waiting for an update

    and
    >
    > Yep.
    >
    > > included a derived recordset which can randomize the data access without
    > > redundancy.

    >
    > Whatever that means.





  10. Re: Database connection to MS Access & MS Foxpro

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


    "Theo Buys" wrote in message
    news:40332e35$0$270$19deed1b@news.inter.NL.net...
    > When working with MFC CDao classes in seperate worker threads I had a
    > problem with the COleVariant types which generate an Access Violation
    > Exception. In my derived classes I have made work-arounds so that the
    > COleVariant is not used.


    My understanding is that the MFC classes are the problem in multithreading.

    >
    > Is ADO multi-thread save, or do I get the same problem?


    I've not done enough on ADO to answer your question, but ADO is the
    technology MS has selected to replace DAO, and is based on OleDB. It is
    also the technology used by Visual Basic. I would presume that much would
    depend on your Provider. ADO is set up as an ActiveX object, and for
    client-server operation/environment.

    >
    > P.S.: I mean with "randomize the data access without redundancy" that I

    can
    > walk through the selected records in a random order while I access each
    > record ones.
    >

    Absolutely. MoveFirst, MoveLast, MoveNext, MovePrevious, and just Move any
    number of records from a given position. Find, etc.





+ Reply to Thread