使用SQLAPI++连接数据库
任何使用SQLAPI++的程序都只需包含一个include
即可。 #include<SQLAPI.h>
连接与断开
连接数据库
一般来说,一个程序有一个连接对象即可,通过调用连接对象的Connect成员函数来配置连接属性。
SAConnection con; //创建连接对象 con.Connect( _TSA("127.0.0.1,5432@test"), // IP地址,断开@数据库名 _TSA("tester"), // 用户名 _TSA("testpwd"), // 密码 SA_PostgreSQL_Client); //连接的数据库
断开连接
直接调用con对象的Disconnect成员函数即可断开连接。
con.Disconnect(); //断开连接