Visualizzazione dei risultati da 1 a 6 su 6
  1. #1

    [C++] Conessione Database Mysql

    Come da titolo come si fa a connettersi con un data base MySql e a far eseguire delle query?
    3/6/2003 è morto l'angelo della mia vita..
    www.markwebinformatica.net
    My BLOG

  2. #2
    ...Terrible warlords, good warlords, and an english song

  3. #3
    Questo lo conoscevo gia (di solito prima di postare controllo le pillole ed eseguo una ricerca sul form )

    Ma se non erro parla di Access a me servirebbe sapere come posso connettermi ad un database MySQL.

    dopo vorrei saper come si eseguono le query;
    e come si stampano i risultati ottenuti(ma penso che basti cout << + nome variabile contenente il risultato.)

    Purtroppo io conosco solo il php e mi piacerrebbe fare con C++ quello che riesco a fare con il php
    3/6/2003 è morto l'angelo della mia vita..
    www.markwebinformatica.net
    My BLOG

  4. #4
    Fi ora ho trovato questo ...


    codice:
    A Simple Example
    
    The following example demonstrates how to open a connection, execute a simple query, and display the results. The code can be found in the file simple1.cc which is located in the examples directory.
    
    #include <iostream>
    #include <iomanip>
    #include <sqlplus.hh>
     
    int main() {
      Connection con("mysql_cpp_data");
      // The full format for the Connection constructor is
      // Connection(cchar *db, cchar *host="",
      //            cchar *user="", cchar *passwd="")
      // You may need to specify some of them if the database is not on
      // the local machine or you database username is not the same as your
      // login name, etc..
     
      Query query = con.query();
      // This creates a query object that is bound to con.
     
      query << "select * from stock";
      // You can write to the query object like you would any other ostrem
     
      Result res = query.store();
      // Query::store() executes the query and returns the results
     
      cout << "Query: " << query.preview() << endl;
      // Query::preview() simply returns a string with the current query
      // string in it.
     
      cout << "Records Found: " << res.size() << endl << endl;
     
      Row row;
      cout.setf(ios::left);
      cout << setw(17) << "Item"
           << setw(4)  << "Num"
           << setw(7)  << "Weight"
           << setw(7)  << "Price"
           << "Date" << endl
           << endl;
     
      Result::iterator i;
      // The Result class has a read-only Random Access Iterator
      for (i = res.begin(); i != res.end(); i++) {
        row = *i;
        cout << setw(17) << row[0]
             << setw(4)  << row[1]
             << setw(7)  << row["weight"]
          // you can use either the index number or column name when
          // retrieving the colume data as demonstrated above.
             << setw(7)  << row[3]
             << row[4] << endl;
      }
      return 0;
    }

    Che ne pensate?

    Mi sembra che come esempio sia buono ...
    3/6/2003 è morto l'angelo della mia vita..
    www.markwebinformatica.net
    My BLOG

  5. #5

    Download

    Ho trovato alcune cose da scaricare...


    * http://www.mysql.com/Downloads/Contr...++-0.02.tar.gz MySQL C++ wrapper library. By Roland Haenel, rh@ginster.net.

    * http://www.mysql.com/Downloads/Contrib/MyDAO.tar.gz MySQL C++ API. By Satish spitfire@pn3.vsnl.net.in. Inspired by Roland Haenel's C++ API and Ed Carp's MyC library.

    * http://www.mysql.com/products/mysql++/ MySQL C++ API (more than just a wrapper library). Originally by kevina@clark.net. Now maintained by Sinisa at MySQL AB.

    * http://nelsonjr.homepage.com/NJrAPI/ A C++ database independent library that supports MySQL.


    Fonte MySQL



    Spero che posano servire a qualcuno che abbia (o avrà) il mio stesso problema.
    3/6/2003 è morto l'angelo della mia vita..
    www.markwebinformatica.net
    My BLOG

  6. #6
    Originariamente inviato da Barman@83
    Questo lo conoscevo gia (di solito prima di postare controllo le pillole ed eseguo una ricerca sul form )

    Ma se non erro parla di Access a me servirebbe sapere come posso connettermi ad un database MySQL.
    L'esempio con DSN di sistema va benissimo anche con MySQL (e anche con gli altri DB)
    Basta solo creare un DSN di sistema (da: pannello di controllo->Strumenti di amministrazione->Origine dati ODBC) che punti al database MySql e non ad Access (il codice resta invariato)
    Sempre negli esempi, trovi query di SELECT, INSERT, UPDATE, DELETE

    p.s. in alternativa puoi utilizzare le librerie C++ messe a disposizione da MySQL (specifiche solo per MySQL)
    ...Terrible warlords, good warlords, and an english song

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.