The following articles mainly describe the use of C ++ database connection to Oracle database, ms SQL, and the actual operation process of MySQL database, I recently found SQLAPI ++ on the Internet. Its main function is to access multiple sqldatabase Oracle (large website database platform ).
SQLServer, DB2, Sybase, Informix, InterBase, SQLBase, MySQL database PostgreSQL) C ++ library. SQLAPI ++ directly calls the DBMS of the local target database management system). Unlike ADO, the APIs use the OLEDBand/orODBC Middle Layer ).
The SQLAPI ++ Library plays the role of middleware for indirect and convenient access to the database, which is why SQLAPI ++ is the fastest way to access the database. You do not need to install or configure the OLEDBand/orODBC driver when developing and publishing your applications.
SQLAPI supports MicrosoftVisualC ++, BorlandC ++ Builder, and GunProjectCandC ++ Compiler.
The sample code is as follows:
- #include<stdio.h> forprintf
- #include<SQLAPI.h>mainSQLAPI++header
- intmain(intargc,char*argv[])
- {
- SAConnectioncon;
Connect Data Objects
- SACommandcmd(
- &con,
- "Selectfid,fvarchar20fromtest_tbl");
Command object, which contains a query statement. You can modify it as needed during testing.
Try
{
Connect to the MySQL database
In this routine, the database is connected to the Oracle (large website database platform) database,
Of course, it can also connect to Sybase, Informix, DB2
SQLServer, InterBase, SQLBaseandODBC
Con. Connect ("test", "tester", "tester", SA_Oracle (large website database platform) _ Client );
Execute the query statement
Cmd. Execute ();
Display query results
- while(cmd.FetchNext())
- {
- printf("Rowfetched:fid=%ld,fvarchar20='%s' ",
- cmd.Field("fid").asLong(),
- (constchar*)cmd.Field("fvarchar20").asString());
- }
Submit current transaction
- con.Commit();
- printf("Rowsselected! ");
- }
- catch(SAException&x)
- {
Exception Handling
- try
- {
Exit current transaction
- con.Rollback();
- }
- catch(SAException&)
- {
- }
Show error message
- printf("%s ",(constchar*)x.ErrText());
- }
- return0;
- }
The official website of SQLAPI ++ is www.sqlapi.com. It provides an evaluation version for the customer to test. Unfortunately, after the database file of the evaluated version is successfully connected to the database, a MessageBox dialog box will pop up. When I tested it, I got bored and cracked it. If necessary, I could download www.szsmart.net from my personal website, but only provided the cracked version of BCB.
The above content is to use C ++ database to connect to Oracle, ms SQL, MySQL database description, hope to bring you some help in this regard.