使用freeTDS在Linux 上连接MSSQL服务器

安装好freeTDS库后,即可使用,并连接操作MSSQL服务器。
源码示例:

//
//  main.cpp
//  testTds
//
//  Created by aiguoma on 15/1/24.
//  Copyright (c) 2015年 aiguoma. All rights reserved.
//
#include 
#include 
#include 
#include 
#include 
#include  //freetds头文件
#include  //freetds
using namespace std;
int main(int argc, const char * argv[])
{
    //char szUsername[32] = "sa";
    //char szPassword[32] = "123456";
    char szDBName[32] = "BWOA"; //数据库名
    //char szServer[32] = "192.168.0.105:1433";//数据库服务器:端口
    //初始化db-library
    dbinit();
    //连接数据库
    LOGINREC *loginrec = dblogin();
    DBSETLUSER(loginrec, "sa");
    DBSETLPWD(loginrec, "sql");
    DBSETLCHARSET(loginrec, "UTF-8");
    DBPROCESS *dbprocess = dbopen(loginrec, "192.168.0.129:1433");//连接数据库
    if(dbprocess == FAIL)
    {
        cout<<"Conect to MS SQL SERVER fail, exit!"< 
 

你可能感兴趣的:(软件配置)