ADO or ODBC?

This is a discussion on ADO or ODBC? within the Windows Programming forums, part of the Platform Specific Boards category; Hi there. I have some experience with Win 32 and MFC, but I have never programmed with data base. I ...

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    87

    ADO or ODBC?

    Hi there.

    I have some experience with Win 32 and MFC, but I have never programmed with data base. I have task to write a program which is written in MFC and use access data base, so ask you which i better ADO or ODBC? And which is easier, so I can learn it
    fast enought.

    Thank you in advance.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    MFC has a decent enough DAO wrapper.

    For Ado you need to either use straight COM or the MFC wrappers for activeX objects.

    I'd go with ADO over ODBC as it's better supported and you can do more with it

  3. #3
    Registered User
    Join Date
    Sep 2003
    Posts
    87
    Thank you, but do you know where I can find resources on this topic?

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786

  5. #5
    Registered User
    Join Date
    Sep 2003
    Posts
    87
    Thank you. But I finally chose ODBC.
    I wrote "odbc c++: in Google, as you told me to do with "ado c++" )
    I learned the basics with the MFC classes for ODBC. But I don't know if I
    copy my program to another pc, which files I must give? The .mdb file, the .exe
    and .dll-files, Is there something more that I must copy?
    Is any registration of the DB required, as I did to make datasource?

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    Depends if the Dll is COM related - if not then you shouldnt need registration.

    Some commercial apps I know of that use ODBC distribute the MDAC redistributable file that can be found on MSDN - this should have everything needed for ODBC (as well as OLEDB and ADO).

  7. #7
    Registered User
    Join Date
    Sep 2003
    Posts
    87
    What about datasource, which I made from
    Start Menu->Control Panel->Administrative Tools->Data Sources
    (ODBC) ? How can I make it on another machine automatically?

  8. #8
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    Not sure...should be part of the ODBC Api...

    That's one of the reasons I like ADO...you can load the MSJET (or whatever) driver on the fly without any need for datasources

  9. #9
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786

  10. #10
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    I cant find one of my examples of using ADO using C++, so I knocked this together

    It works with VC++. You need to pass the FULL PATH of the database (as provided) as a parameter once you have built the exe file
    Attached Files Attached Files

  11. #11
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,854
    >>What about datasource, which I made from
    Start Menu->Control Panel->Administrative Tools->Data Sources
    (ODBC) ? How can I make it on another machine automatically?

    Like so


    Code:
    	CString	Attrib;
    	int	iRet=0;
    
    	Attrib.Format("%s","DSN=DamageMod;DBQ=C:\\databases\\DatabaseName.mdb;DESCRIPTION=Test;READONLY=FALSE;EXCLUSIVE=FALSE;");
    
    	//this adds a SYSTEM DSN for the database to use
    	iRet=::SQLConfigDataSource(NULL,ODBC_ADD_SYS_DSN,"Microsoft Access Driver (*.mdb)",Attrib);
    	if(!iRet)
    	{
    		iRet=GetLastError();
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  12. #12
    Registered User
    Join Date
    Sep 2003
    Posts
    87
    OK. I learned how to use CDatabase and CRecordset.

    But I have question. How much of the SQL standart is supported
    by this classes. Can I use LEFT/RIGHT JOIN in CRecordset::Open()
    and nested queries in CDatabase::ExecuteSQL().

    And if this functionality is not supported directly how can I use it?

  13. #13
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    Have you tried?

  14. #14
    Registered User
    Join Date
    Sep 2003
    Posts
    87
    I tried today to use one INSERT query like this:
    Code:
    INSERT INTO Sometable(PersonID,...) VALUES(
    (SELECT Id FROM People WHERE Name='some name'),...)
    And it says:

    Syntax error in INSERT INTO statement.

    And I don't know weather or not my error is in the syntax
    or the CDatabase don't support nested queries.

  15. #15
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Here is a good JET SQL reference.

    As you can see, you need to lose the VALUES() for a multiple record insert.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help With ODBC Code
    By zzman in forum C Programming
    Replies: 9
    Last Post: 08-22-2008, 03:18 PM
  2. Oracle cursor in ODBC
    By Mortissus in forum C Programming
    Replies: 4
    Last Post: 09-10-2007, 01:19 PM
  3. Multi-Threading and ADO
    By chandhru in forum Windows Programming
    Replies: 19
    Last Post: 05-15-2004, 11:53 AM
  4. odbc with vc++
    By doublin in forum C++ Programming
    Replies: 1
    Last Post: 03-21-2003, 09:09 AM
  5. Linking error using ODBC with C and BCC32
    By D@nnus in forum C++ Programming
    Replies: 0
    Last Post: 11-17-2001, 04:11 AM

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