ConnObj

[email protected][email protected]

 

#pragma once
#include <stdio.h>
#include <string>
#include <list>
#include <iostream>
#import "c:\Program Files\Common Files\System\ADO\msado15.dll"  no_namespace rename("EOF", "adoEOF")
using namespace std;

class ConnObj
{
public:
 _ConnectionPtr conn;
 bool isUsed;
 bool isTrans;
 int usedCount;
public:
 void OpenConn();
 void CloseConn();
public:
 ConnObj(void);
 ~ConnObj(void);
};

#include "StdAfx.h"
#include "ConnObj.h"

ConnObj::ConnObj(void)
{
 isUsed = false;
 isTrans = false;
 usedCount = 0;
}

ConnObj::~ConnObj(void)
{
}

void ConnObj::OpenConn()
{
 _bstr_t strConnect= "Provider=SQLOLEDB;Server=localhost;Database=bty_db_main;uid=sa; pwd=123";


 conn.CreateInstance("ADODB.Connection");
 conn->Open(strConnect,"","",adModeUnknown);
}

void ConnObj::CloseConn()
{
 conn->Close();
 conn = NULL;
}

你可能感兴趣的:(on)