91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 85.15MB
    文件類型: .rar
    金幣: 1
    下載: 0 次
    發布日期: 2023-05-15
  • 語言: C/C++
  • 標簽: MySQL??VS2015??

資源簡介

自己封裝的一個簡單的VS2015平臺下,C++操作MySQL數據庫;可實現連接,增刪改查等功能。

資源截圖

代碼片段和文件信息

#include?“stdafx.h“??
#include?“MysqlConInfo.h“??


MySQLInterface::MySQLInterface()?:
ErrorNum(0)?ErrorInfo(“ok“)
{
mysql_library_init(0?NULL?NULL);
mysql_init(&MysqlInstance);

//?設置字符集,否則無法處理中文
mysql_options(&MysqlInstance?MYSQL_SET_CHARSET_NAME?“gbk“);
}

MySQLInterface::~MySQLInterface()
{
Close();
}

//?設置連接信息
void?MySQLInterface::SetMySQLConInfo(CString?server?CString?usernameCString?password?CString?database?CString?port)
{

}
void?MySQLInterface::SetMySQLConInfo(char*?server?char*?username?char*?password?char*?database?int?port)
{
MysqlConInfo.server?=?server;
MysqlConInfo.user?=?username;
MysqlConInfo.password?=?password;
MysqlConInfo.database?=?database;
MysqlConInfo.port?=?port;
}

//?打開連接
bool?MySQLInterface::Open()
{
if?(mysql_real_connect(&MysqlInstance?MysqlConInfo.server?MysqlConInfo.user
MysqlConInfo.password?MysqlConInfo.database?MysqlConInfo.port?0?0)?!=?NULL)
{
return?true;
}
else
{
ErrorIntoMySQL();
return?false;
}
}

bool?MySQLInterface::OpenSql(CString?server?CString?username?CString?password?CString?database?CString?port)
{
USES_CONVERSION;
if?(mysql_real_connect(&MysqlInstance?W2A(server)?W2A(username)
W2A(password)?W2A(database)?_ttoi(port)?0?0)?!=?NULL)
{
return?true;
}
else
{
ErrorIntoMySQL();
return?false;
}
}
//?斷開連接
void?MySQLInterface::Close()
{
mysql_close(&MysqlInstance);
}

//讀取數據
bool?MySQLInterface::Select(const?string&?Querystr?vector?>&?data)
{
if?(0?!=?mysql_query(&MysqlInstance?Querystr.c_str()))
{
ErrorIntoMySQL();
return?false;
}

Result?=?mysql_store_result(&MysqlInstance);

//?行列數
int?row?=?mysql_num_rows(Result);
int?field?=?mysql_num_fields(Result);

MYSQL_ROW?line?=?NULL;
line?=?mysql_fetch_row(Result);

int?j?=?0;
string?temp;
vector?>().swap(data);
while?(NULL?!=?line)
{
vector?linedata;
for?(int?i?=?0;?i? {
if?(line[i])
{
temp?=?line[i];
linedata.push_back(temp);
}
else
{
temp?=?““;
linedata.push_back(temp);
}
}
line?=?mysql_fetch_row(Result);
data.push_back(linedata);
}
return?true;
}

//?其他操作
bool?MySQLInterface::Query(const?string&?Querystr)
{
if?(0?==?mysql_query(&MysqlInstance?Querystr.c_str()))
{
return?true;
}
ErrorIntoMySQL();
return?false;
}

//?插入并獲取插入的ID針對自動遞增ID
int?MySQLInterface::GetInsertID(const?string&?Querystr)
{
if?(!Query(Querystr))
{
ErrorIntoMySQL();
return?ERROR_QUERY_FAIL;
}
//?獲取ID
return?mysql_insert_id(&MysqlInstance);
}

//錯誤信息
void?MySQLInterface::ErrorIntoMySQL()
{
ErrorNum?=?mysql_errno(&MysqlInstance);
ErrorInfo?=?mysql_error(&MysqlInstance);
}


//判斷數據庫是否存在,不存在則創建數據庫,并打開
bool?MySQLInterface::createDatabase(string&?dbname)
{
std::string?queryStr?=?“create?database?if?not?exists?“;
queryStr?+=?dbname;
if?(0?==?mysql_

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

????..A..H.?????45568??2018-09-06?15:52??MySqlTest\.vs\MySqlTest\v14\.suo

?????文件??????61440??2018-09-05?23:47??MySqlTest\Debug\MySqlTest.pdb

?????文件??122355712??2018-09-05?23:50??MySqlTest\ipch\MYSQLTEST-12bb64a\MYSQLTEST-856acd40.ipch

?????文件??103481344??2018-09-05?23:44??MySqlTest\ipch\MYSQLTEST-12bb64a\MYSQLTEST-adecefe2.ipch

?????文件????????489??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.log

?????文件??????97784??2018-09-05?23:45??MySqlTest\MySqlTest\Debug\MySqlTest.obj

?????文件???55246848??2018-09-05?23:45??MySqlTest\MySqlTest\Debug\MySqlTest.pch

?????文件??????69768??2018-09-05?23:45??MySqlTest\MySqlTest\Debug\MySqlTest.res

?????文件???????2126??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\CL.command.1.tlog

?????文件?????100532??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\CL.read.1.tlog

?????文件???????1570??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\CL.write.1.tlog

?????文件??????????2??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\link-cvtres.read.1.tlog

?????文件??????????2??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\link-cvtres.write.1.tlog

?????文件??????????2??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\link-mt.read.1.tlog

?????文件??????????2??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\link-mt.write.1.tlog

?????文件??????????2??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\link-rc.read.1.tlog

?????文件??????????2??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\link-rc.write.1.tlog

?????文件??????????2??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\link.5632-cvtres.read.1.tlog

?????文件??????????2??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\link.5632-cvtres.write.1.tlog

?????文件??????????2??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\link.5632-mt.read.1.tlog

?????文件??????????2??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\link.5632-mt.write.1.tlog

?????文件??????????2??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\link.5632-rc.read.1.tlog

?????文件??????????2??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\link.5632-rc.write.1.tlog

?????文件??????????2??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\link.5632.read.1.tlog

?????文件??????????2??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\link.5632.write.1.tlog

?????文件??????????2??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\link.command.1.tlog

?????文件??????????2??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\link.read.1.tlog

?????文件??????????2??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\link.write.1.tlog

?????文件????????184??2018-09-05?23:47??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\MySqlTest.lastbuildstate

?????文件????????370??2018-09-05?23:45??MySqlTest\MySqlTest\Debug\MySqlTest.tlog\rc.command.1.tlog

............此處省略69個文件信息

評論

共有 條評論