mysql5.7.24 dll库文件

时间:2022-02-11 15:56:40
【文件属性】:

文件名称:mysql5.7.24 dll库文件

文件大小:8.15MB

文件格式:ZIP

更新时间:2022-02-11 15:56:40

mysql

mysql库文件和头文件,可以用VC调用库函数 #include "stdafx.h" #include "mysql.h" #include #include < list > #pragma comment(lib,"libmysql.lib") using namespace std; int main() { char strSQL[256] = { 0 }; MYSQL mysql; mysql_init(&mysql;); char* host = "localhost"; char* user = "root"; char* pwd = ""; char* dbname = "test"; int port = 3306; if (!mysql_real_connect(&mysql;, host, user, pwd, dbname, port, NULL, 0)) { printf("%s\n", mysql_error(&mysql;)); printf("connect failed\n"); return 1; } // query char* tbname = "student"; sprintf(strSQL, "select * from %s", tbname); if (mysql_real_query(&mysql;, strSQL, strlen(strSQL))) { printf("%s\n", mysql_error(&mysql;)); printf("read failed!\n"); mysql_close(&mysql;); return 2; } //get result MYSQL_RES* result; if (!(result = mysql_use_result(&mysql;))) { printf("%s\n", mysql_error(&mysql;)); printf("read result failed!\n"); mysql_close(&mysql;); return 3; } //show data MYSQL_ROW row; int num = mysql_num_fields(result);// field number while (row = mysql_fetch_row(result)) { for (int i = 0; i < num; ++i) printf("%s\t", row[i]); printf("\n"); } mysql_free_result(result); mysql_close(&mysql;); system("Pause"); return 0; }


网友评论