本文整理汇总了C++中CConnect::Connect方法的典型用法代码示例。如果您正苦于以下问题:C++ CConnect::Connect方法的具体用法?C++ CConnect::Connect怎么用?C++ CConnect::Connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CConnect
的用法示例。
在下文中一共展示了CConnect::Connect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Connect
SQLRETURN ODBC::Connect(SQLHDBC ConnectionHandle,
SQLCHAR *ServerName,
SQLSMALLINT NameLength1,
SQLCHAR *UserName,
SQLSMALLINT NameLength2,
SQLCHAR *Authentication,
SQLSMALLINT NameLength3)
{
SQLRETURN rc;
CConnect *pConnect;
if (! gDrvrGlobal.gHandle.validateHandle(SQL_HANDLE_DBC, ConnectionHandle))
return SQL_INVALID_HANDLE;
pConnect = (CConnect *)ConnectionHandle;
rc = pConnect->Connect(ServerName, NameLength1, UserName, NameLength2, Authentication, NameLength3,
TRUE);
return rc;
}
示例2: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
bool bReturn = false;
for(int i = 0;i < 5;++i)
{
//std::string host = "10.0.0.218";
//std::string user = "root";
//std::string password = "tiptip";
//std::string dbname = "test";
//WORD port = MYSQL_PORT;
CConnect * conn = new CConnect();
bReturn = false;
//bReturn = conn->Connect(host, user, password, dbname, port);
bReturn = conn->Connect("localhost", "root", "tiptop", "test", MYSQL_PORT);
if (bReturn)
{
std::cout<<"连接数据库成功!!!"<<endl;
}
else
{
std::cout<<"连接数据库失败!!!"<<endl;
}
//bReturn = conn->Connect("10.0.0.218", "root", "tiptop", "test", MYSQL_PORT);
CManagerPool::GetInitInstance().AddConObject(conn);
}
CSqlClient client;
COperMysql store;
store.SetTransAction(client.GetConnect());
//先删除数据表
std::string s_sql = "drop table processingtransactioninterface";//删除表
if(!store.Exec(s_sql))
{
//删除表失败
std::cout<<"drop table fail"<<endl<<store.What()<<endl;
}
else
{
std::cout<<"drop table success"<<endl;
}
//创建数据表,字段 actid 设置了自增列属性
s_sql = "create table processingtransactioninterface(";
s_sql += "actid integer not null AUTO_INCREMENT,";
s_sql += "acttype integer not null,resourceid integer not null,";
s_sql += " subresoureid integer, actdate varchar(19), actresult integer,";
s_sql += " memo varchar(50) null,primary key(actid))";
if(!store.Exec(s_sql))
{
//创建表失败
std::cout<<"create table fail"<<endl;
return -1;
}
else
{
std::cout<<"create table success"<<endl;
std::cout<<s_sql.c_str()<<endl;
}
std::cout<<"开始运行线程……"<<endl;
unsigned long p1 = 0;
::CreateThread(0,0,(funcptr)show,0,0,&p1);
unsigned long p2 = 0;
::CreateThread(0,0,(funcptr)update,0,0,&p2);
unsigned long p3 = 0;
::CreateThread(0,0,(funcptr)insert,0,0,&p3);
system("pause");
return 0;
}