2011-12-28 53 views
1

我正在使用Microsoft Visual C++ 2008 Express Edition。将MVC++与SQLAPI ++连接

我跟着SQL API网站[http://www.sqlapi.com/index.html]。

我已经安装了SqlApi ++,但但我的编译器没有检测#include <SQLAPI.h>

我在做什么错?

这是我的代码:

#include <stdio.h> // for printf 
#include <SQLAPI.h> // main SQLAPI++ header 

int main(int argc, char* argv[]) 
{ 
    SAConnection con; // create connection object 

    try 
    { 
     // connect to database 
     // in this example it is Oracle, 
     // but can also be Sybase, Informix, DB2 
     // SQLServer, InterBase, SQLBase and ODBC 
     con.Connect(
      "test",  // database name 
      "tester", // user name 
      "tester", // password 
      SA_Oracle_Client); 

     printf("We are connected!\n"); 

     // Disconnect is optional 
     // autodisconnect will ocur in destructor if needed 
     con.Disconnect(); 

     printf("We are disconnected!\n"); 
    } 
    catch(SAException &x) 
    { 
     // SAConnection::Rollback() 
     // can also throw an exception 
     // (if a network error for example), 
     // we will be ready 
     try 
     { 
      // on error rollback changes 
      con.Rollback(); 
     } 
     catch(SAException &) 
     { 
     } 
     // print error message 
     printf("%s\n", (const char*)x.ErrText()); 
    } 

    return 0; 
} 

回答

0

请检查您是否添加了包括目录与SQLAPI头文件插入到另外包括为你的项目目录(开放项目的属性页中,选择标签C++ \常规列表,chnage财产“附加包含目录”添加包括子目录SQLAPI ++分布。

可能,你必须做的SQLAPI库相同(路径添加到的lib文件夹将财产“附加天秤座ry目录“选项卡”链接器/常规“)

+1

@Seril我这样做..我的观点是,现在我需要打开我的sqlApI检查数据库和表present.i无法看到任何地方下程序files.I只是想做的就像我们在sqlserver 2005中做什么。我希望sqlApi应该提供这个选项 – user1118700 2011-12-30 05:41:47

+1

@seril我已经做了更改。现在编译器能够检测到头文件。现在这个con.Connect( “测试“,//数据库名称 ”tester“,//用户名称 ”tester“,//密码 SA_Oracle_Client); 有问题..我想我需要打开我的sqlapi然后创建新的数据库,然后我认为它会工作。你只是指导我如何做到这一点? – user1118700 2011-12-30 05:55:43