main.cpp
#include "sqlConnection.h"
#include <iostream>
int main(){
sqlConnection *sqlC = new sqlConnection();
sqlC->ifSucceed();
}
sqlConnection.h
#include <Windows.h>
#include <stdio.h>
#include <winsock.h>
#include "mysql.h"
#include <iostream>
#pragma once
using namespace std;
class sqlConnection
{
public:
sqlConnection();
~sqlConnection();
void ifSucceed();
MYSQL mysql;
MYSQL_RES *result;
MYSQL_ROW row;
};
sqlConnection.cpp
#include "sqlConnection.h"
sqlConnection::sqlConnection()
{
mysql_init(&mysql);
mysql_real_connect(&mysql, "567aaffa1a70e.sh.cdb.myqcloud.com", "cb_outerroot", "cppw123", "librarySys", 7726, NULL, 0);
}
void sqlConnection::ifSucceed(){
char *sql = "select * from tb_bookcase";
mysql_query(&mysql, sql);
result = mysql_store_result(&mysql);
if ((row = mysql_fetch_row(result)) != NULL){
cout << "succeed!" << endl;
}else{
cout << "faiiiiiiiiled" << endl;
}
}
sqlConnection::~sqlConnection()
{
}
存在libmysql.dll报错信息为:
0x00007FFED00441E6 (libmysql.dll) (librarySys.exe 中)处有未经处理的异常: 0xC0000005: 读取位置 0x0000000000000010 时发生访问冲突。
然后被迫中断,目前vs给我一个选项 更改现有PDB和二进制文件搜索路径并重试,但是我才疏学浅,确实不懂
若把libmysql.dll文件删除 则报错信息为:
无法启动此程序,因为计算机中丢失libmysql.dll。尝试重新安装该程序以解决问题。
真的挺困惑的,也很无奈。这种bug实在不知道如何改。
顺便一提,我已经尝试很多种vs2013连接mysql的方法,每次都是各种奇怪的报错。求大神解救!若有人为很不错的连接mysql的方法 也请告知!
Download the correct version of libmysql.dll
Maybe this dependent libmysql.dll conflicts with your other libraries
You may need the VS2013 version of libmysql.lib.
How to manage the dll version? Is there a field that uniformly identifies the version of the dll file? How to judge the interdependence relationship? Apart from trying constantly
I have encountered it before, there is a relationship between downloading lib and dll versions.