CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: ODBC DSN's

  1. #1
    Join Date
    Apr 1999
    Posts
    18

    ODBC DSN's

    I've got a program which needs to preview data which is stored in a variety of database formats. The user selects the file and then the program needs to open the database and read the headings and a sample of the data to display in a grid. If I were to use ODBC is there anyway to specify the DSN through code, or does the user have to go through the control panel to do this?

    Cheers,
    Craig.



  2. #2
    Join Date
    May 1999
    Posts
    6

    Re: ODBC DSN's

    Hi!

    You do not need an ODBC-driver. You can do this drictely with DAO too. Try the following:

    CDaoDatabase OdbcDB;
    CDaoRecordset *OdbcTable;

    OdbcDb.Open("c:\\...your path to the ODBC source", FALSE, FALSE, "FoxPro 2.6; /*or another typ, see MSDN for the other definitions*/");

    OdbcTable = new CDaoRecordset(&OdbcDb);

    OdbcTable->Open(dbOpenDynaset, "select * from ...", dbSeeChanges);

    /*-------------------------------*/
    ... or via ODBC-DSN
    OdbcTable = new CRecordset(...);
    OdbcTable->Open(dynaset, "ODBC;DSN=...", none | skipDeletedRecords);

    I hope this will work.

    Marc


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured