Connect Oracle,ms Sql,mysql Database with C + + library

Source: Internet
Author: User
Tags commit exception handling informix odbc ole sybase mysql database oracle database

Recently found a good thing on the Internet sqlapi++, it is available to access multiple SQL databases (oracle,sql server,db2,sybase,informix,interbase,sqlbase,mysql,postgresql) C+ + Library. sqlapi++ directly invokes the APIs of the local Target database management system (DBMS) (unlike ADO using the OLE DB and/or ODBC intermediate). The sqlapi++ Library acts as a middleware to indirectly access the role of the database, which is why sqlapi++ is the quickest way to access a database. You no longer need to install and configure OLE DB and/or ODBC drivers when developing and publishing your applications.

The development platform supported by SQLAPI is Microsoft Visual C++,borland C + + Builder,gun Project C and C + + Compiler.

The sample code is as follows:

#include <stdio.h>/For printf
#include <SQLAPI.h>//main sqlapi++ header
int main (int argc, char* argv[])
{
Saconnection con; Connecting Data Objects
Sacommand cmd (
&con,
"Select FID, Fvarchar20 from Test_tbl"); Command object, which contains a query statement,//You can modify it as needed when you test it.
Try
{
Connecting to a database
The Oracle database is connected to this routine.
Of course it can also be connected to Sybase, Informix, DB2
SQL Server, InterBase, SQLBase and ODBC
Con. Connect ("Test", "Tester", "tester", sa_oracle_client);
This paper studies from C++builder-HTTP://WWW.CCRUN.COM/ARTICLE.ASP?I=1020&AMP;D=SSOQRD
Executing query statements
Cmd. Execute ();
Show results after a query
while (CMD. Fetchnext ())
{
printf ("Row Fetched:fid =%ld, Fvarchar20 = '%s ' \ n",
Cmd. Field ("FID"). Aslong (),
(const char*) cmd. Field ("Fvarchar20"). asstring ());
}
Commit the current transaction
Con.commit ();
printf ("Rows selected!\n");
}
catch (Saexception &x)
{
Exception handling
Try
{
Exit Current transaction
Con. Rollback ();
}
catch (Saexception &)
{
}
Display error messages
printf ("%s\n", (const char*) x.errtext ());
}
return 0;
}

Sqlapi++ 's official website is www.sqlapi.com, which provides evaluation versions to customers for testing. Unfortunately, a MessageBox dialog box pops up after the evaluation version of the library file succeeds in connecting to the database. I was very annoyed when testing it, and then I cracked it, if necessary, can go to my personal website to download it www.szsmart.net, but only provide BCB cracked version.

Sqlapi Library crack Download

This article supporting source code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.