用C++库连接Oracle, MS SQL, MySQL等数据库

最近在网上找到一个好东西SQLAPI++,它是可以访问多个SQL数据库(Oracle, SQL Server, DB2, Sybase, Informix, InterBase, SQLBase, MySQL, PostgreSQL)C++库。SQLAPI++直接调用本地目标数据库管理系统(DBMS)的API(不像ADO一样使用OLEDB and/or ODBC 中间层)。SQLAPI++库扮演了一个中间件以间接方便访问数据库的角色,这就是为什么SQLAPI++是访问数据库最快的方法。在开发和发布您的应用程序时不再需要安装和配置OLEDB and/or ODBC的驱动。
SQLAPI支持的开发平台有Microsoft Visual C++,Borland C++ Builder,Gun Project C and C++ Compiler。

示例代码如下:
#include <stdio.h>  // for printf
#include <SQLAPI.h> // main SQLAPI++ header

int main(int argc, char* argv[])
{
    SAConnection con; // 连接数据对象
    SACommand cmd(
        &con,
        "Select fid, fvarchar20 from test_tbl"); // 命令对象,其中包含了一个查询语句,//你在测试的时候可以根据需要修改它。
// 本文转自 C++Builder 研究 - http://www.ccrun.com/article.asp?i=1020&d=ssoqrd
   
    try
    {       
        // 连接数据库
        // 在这个例程中连接的是Oracle数据库,
        // 当然它也可以连接 Sybase, Informix, DB2
        // SQLServer, InterBase, SQLBase and ODBC
        con.Connect("test""tester""tester", SA_Oracle_Client);

        // 执行查询语句
        cmd.Execute();
        // 显示查询后的结果
        while(cmd.FetchNext())
        {
            printf("Row fetched: fid = %ld, fvarchar20 = '%s'\n"
                cmd.Field("fid").asLong(),
                (const char*)cmd.Field("fvarchar20").asString());
        }

        // 提交当前事务
        con.Commit();

        printf("Rows selected!\n");
    }
    catch(SAException &x)
    {
        // 异常处理
        try
        {
            // 退出当前事务
            con.Rollback();
        }
        catch(SAException &)
        {
        }
        // 显示错误信息
        printf("%s\n", (const char*)x.ErrText());
    }
   
    return 0;
}
SQLAPI++的官方网站是www.sqlapi.com,它提供评估版本给客户测试。可惜评估版本的库文件在连接数据库成功后,会弹出一个MessageBox对话框.

posted on 2008-01-02 09:16 lovetiffany 阅读(1681) 评论(3)  编辑 收藏 引用

评论

# re: 用C++库连接Oracle, MS SQL, MySQL等数据库 2008-01-02 14:38 <a href=http://minidx.com>minidxer</a>

原文后面还有几句,帮你补充完整:

我在测试它的时候觉得很烦,便把它破解掉了,如果需要可以到我的个人网站去下载它www.szsmart.net,不过只提供BCB的破解版本。

  SQLAPI Library Crack下载

  http://down.ddvip.com/view/11809742917667.html  回复  更多评论   

# re: 用C++库连接Oracle, MS SQL, MySQL等数据库 2008-03-19 18:12 8340

没开放代码的不敢用啊。  回复  更多评论   

# re: 用C++库连接Oracle, MS SQL, MySQL等数据库 2010-06-30 16:39 tiffany jewellery

<a href="http://www.sterlingtiffany.com/">tiffany jewellery</a> is the best online shoping.<a href="http://www.tiffanyforsale.com">tiffany">http://www.tiffanyforsale.com">tiffany sale</a> good <a href="http://www.tiffanyforsale.com">tiffany">http://www.tiffanyforsale.com">tiffany on sale</a> Present give you!!   回复  更多评论   


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

导航

统计

常用链接

留言簿(4)

随笔档案

网站收藏

搜索

最新评论

阅读排行榜

评论排行榜