Thread: Good Books?

  1. #1
    Registered User dizz's Avatar
    Join Date
    Nov 2002
    Posts
    41

    Good Books?

    Does anyone know of any books that explain connecting to Access Databses using C++ console mode...

    Also any online tutorials or code snippets would be good!

  2. #2
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    you can't just flat out access a database like MS access or something....I'm not sure how some of the higher end db's work like oracle and the like....it also depends on what one you plan to interface with, some have different commands, some even organize themselves differently. You're better off making your own database than trying to hack and access other db's from an app, it'd take less time and effort. If you plan on making a front-end program to something like MS access, use visual basic, not c++.
    Any other questions?
    PHP and XML
    Let's talk about SAX

  3. #3
    Registered User dizz's Avatar
    Join Date
    Nov 2002
    Posts
    41
    what... i have seen it done?

    straight through C++, also i have created my own DB and no it is not as simple as just connecting to an ACCESS DB..

    o well anyone else?

  4. #4
    Registered User dizz's Avatar
    Join Date
    Nov 2002
    Posts
    41
    Code:
    //**************************************
    //     
    // Name: Access MDB
    // Description:To open MS Access or Ms S
    //     QL server database using C/C++ or VC++
    // By: Mokarrabin A Rahman
    //
    // Returns:Shows some recordsets
    //
    // Assumes:Change the name of the databa
    //     se to any database and place it in the s
    //     ame directory as the .exe. You shoul als
    //     o change the SQL to your particular data
    //     base. You may change the connect string 
    //     to connect to MS SQL Server.
    //
    // Side Effects:Great
    //
    //This code is copyrighted and has// limited warranties.Please see http://
    //     www.Planet-Source-Code.com/xq/ASP/txtCod
    //     eId.1371/lngWId.3/qx/vb/scripts/ShowCode
    //     .htm//for details.//**************************************
    //     
    
    #import "c:\Program Files\Common Files\System\ADO\msado15.dll" \
    no_namespace rename("EOF", "EndOfFile")
    // This code comes from : www.geocities.
    //     com/mokarrabin
    #include <stdio.h>
    #include <iostream.h>
    void main(void)
    
    
        {
        CoInitialize(NULL);
        try 
    
    
            {
            _RecordsetPtr pRst("ADODB.Recordset");
            // Connection String
            _bstr_t strCnn("DRIVER={Microsoft Access Driver (*.mdb)};UID=admin;DBQ=GBOOK.mdb");
            	 // Open table
            	pRst->Open("SELECT * FROM ProductService where ProductService like '%samir%';", strCnn, adOpenStatic, adLockReadOnly, adCmdText);
            	 
            	 pRst->MoveFirst();
    
    
                	 while (!pRst->EndOfFile) {
                		 cout<<(char*) ((_bstr_t) pRst->GetFields()->GetItem("ProductService")->GetValue())<<endl;
                		 pRst->MoveNext();
                	 }
                	 pRst->Close(); 
                	 
            }
            catch (_com_error &e)
    
    
                {
                cout<<(char*) e.Description();
            }
            ::CoUninitialize();
        }
    Here ya go.. i just need an explanation on how it is working... i understand how to access them in VBscript for ASP and it seems similar but there is still some syntax that i do not understand!

  5. #5
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    well, im not sure what you need broken down....but this is the important part right here:
    Code:
                	 while (!pRst->EndOfFile) {
                		 cout<<(char*) ((_bstr_t) pRst->GetFields()->GetItem("ProductService")->GetValue())<<endl;
                		 pRst->MoveNext();
                	 }
    it has a pointer to a file, and while there's still data left (not the end of the file) it spits out the text within the feilds. Then it moves on to the next feild........it shows nothing on how to send the recordset new data and the like.....you'll have to dig deeper to find out how to do that. The reason i thought it would be so difficult is that i had not known someone had already found out how to use the access dll in this manner.
    PHP and XML
    Let's talk about SAX

  6. #6
    Registered User dizz's Avatar
    Join Date
    Nov 2002
    Posts
    41
    understandable.. if anyone else know how to use this please post some links or a book

    thanx!

  7. #7
    Registered User
    Join Date
    Oct 2002
    Posts
    291
    Originally posted by Waldo2k2
    You're better off making your own database than trying to hack and access other db's from an app, it'd take less time and effort.
    Any other questions?
    Know any good tutorials or free online books that cover that topic ?

    Cheers.

  8. #8
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    i might as well write one
    as long as you don't mind waiting a week
    PHP and XML
    Let's talk about SAX

  9. #9
    Registered User
    Join Date
    Jun 2002
    Posts
    82
    Originally posted by Waldo2k2
    i might as well write one
    as long as you don't mind waiting a week
    I can wait a week for information like that!

    Oh, and I like Perl for database interfacing, but I've only used it with Oracle, not Access.
    Claus Hetzer
    Compiler: Borland 5.5 (on Windows)
    Solaris CC (on Unix)
    Known Languages: C++, MATLAB, Perl, Java

  10. #10
    Registered User
    Join Date
    Oct 2002
    Posts
    291
    Originally posted by Waldo2k2
    i might as well write one
    as long as you don't mind waiting a week
    Thats brilliant

  11. #11
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    just a guess (?)

    I'm just guessing here... But Access is ODBC compliant (Open Database Connectivity). So you may want to look-up information on writing ODBC applications. As I understand it, this is how Crystal Reports works... by interfacing with the ODBC database.

    You might look into OLE (Object Linking and Embedding) and DAO (Direct Object Access) too.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In a game Engine...
    By Shamino in forum Game Programming
    Replies: 28
    Last Post: 02-19-2006, 11:30 AM
  2. Good books for learning WIN32 API
    By Junior89 in forum Windows Programming
    Replies: 6
    Last Post: 01-05-2006, 05:38 PM
  3. Good books to learn windows programming?
    By RetroGamer1991 in forum Windows Programming
    Replies: 4
    Last Post: 06-17-2003, 01:06 PM
  4. Any good books on C ?
    By deadsam in forum C Programming
    Replies: 8
    Last Post: 05-28-2003, 10:38 AM
  5. Good C Books
    By mattz in forum C Programming
    Replies: 10
    Last Post: 12-05-2001, 11:59 AM