当前位置: 首页 > news >正文

个人网站psd怎么推广销售

个人网站psd,怎么推广销售,奖励软件下载网站,做管理信息的网站吗文章目录 0. Mysql安装与开发环境配置1. win10 Navicat 连接虚拟机的MySQL需要关闭防火墙2. 由于找不到libmysql.dIl, 无法继续执行代码。重新安装程序可能会解决此问题。3. 测试连接数据库,并插入数据4. C封装MySQL增删改查操作 0. Mysql安装与开发环境配置 MySQL…

文章目录

  • 0. Mysql安装与开发环境配置
  • 1. win10 Navicat 连接虚拟机的MySQL需要关闭防火墙
  • 2. 由于找不到libmysql.dIl, 无法继续执行代码。重新安装程序可能会解决此问题。
  • 3. 测试连接数据库,并插入数据
  • 4. C++封装MySQL增删改查操作

0. Mysql安装与开发环境配置

MySQL安装_win10(超详细)

C/C++访问MySQL数据库

1. win10 Navicat 连接虚拟机的MySQL需要关闭防火墙

  1. 查看防火墙端口开放的情况:
service firewalld status
  1. 关闭防火墙:
systemctl stop firewalld

2. 由于找不到libmysql.dIl, 无法继续执行代码。重新安装程序可能会解决此问题。

D:\MySQL\mysql-8.0.33-winx64\lib目录下的libmysql.dll拷贝到E:\Code\VS2022\student_manager\student_manager

3. 测试连接数据库,并插入数据

#include <iostream>
#include <mysql.h>
#include <string>using namespace std;const char* host = "127.0.0.1";
const char* user = "root";
const char* pw = "111111";
const char* database_name = "student_manager";
const int port = 3306;typedef struct Student {int student_id;string student_name;string class_id;
}Student;int main() {MYSQL* con = mysql_init(NULL);// 设置字符编码mysql_options(con, MYSQL_SET_CHARSET_NAME, "GBK");if (!mysql_real_connect(con, host, user, pw, database_name, port, NULL, 0)) {fprintf(stderr, "Failed to connect to database : Error:%s\n", mysql_errno(con));return -1;}Student stu = { 1001, "吴彦祖", "计算机2班" };char sql[256];sprintf_s(sql, "insert into students(student_id, student_name, class_id) values(%d, '%s', '%s');", stu.student_id, stu.student_name.c_str(), stu.class_id.c_str());if (mysql_query(con, sql)) {fprintf(stderr, "Failed to insert data : Error:%s\n", mysql_errno(con));return -1;}mysql_close(con);return 0;
}

4. C++封装MySQL增删改查操作

// StudentManager.h
#ifndef STUDENTMANAGER_H
#define STUDENTMANAGER_H#include <mysql.h>
#include <string>
#include <vector>
#include <iostream>using namespace std;typedef struct Student {int student_id;string student_name;string class_id;
}Student;class StudentManager {StudentManager();~StudentManager();public: // 单例模式:只创建一个实体,即只创建一个学生管理类即可static StudentManager* GetInstance() {static StudentManager StudentManager;return &StudentManager;}public:bool insert_student(Student& stu);bool update_student(Student& stu);bool delete_student(int student_id);vector<Student> get_students(string condition = "");private:MYSQL* con;const char* host = "127.0.0.1";const char* user = "root";const char* pw = "111111";const char* database_name = "student_manager";const int port = 3306;
};#endif // STUDENTMANAGER_H
// StudentManager.cpp
#include "StudentManager.h"StudentManager::StudentManager() {con = mysql_init(NULL);// 设置字符编码mysql_options(con, MYSQL_SET_CHARSET_NAME, "GBK");if (!mysql_real_connect(con, host, user, pw, database_name, port, NULL, 0)) {fprintf(stderr, "Failed to connect to database : Error:%s\n", mysql_errno(con));exit(1);}
}StudentManager::~StudentManager() {mysql_close(con);
}bool StudentManager::insert_student(Student& stu) {char sql[256];sprintf_s(sql, "INSERT INTO students(student_id, student_name, class_id) values(%d, '%s', '%s');",stu.student_id, stu.student_name.c_str(), stu.class_id.c_str());if (mysql_query(con, sql)) {fprintf(stderr, "Failed to insert data : Error:%s\n", mysql_errno(con));return false;}return true;
}bool StudentManager::update_student(Student& stu) {char sql[256];sprintf_s(sql, "UPDATE students SET student_name = '%s', class_id = '%s' WHERE student_id = %d", stu.student_name.c_str(), stu.class_id.c_str(), stu.student_id);if (mysql_query(con, sql)) {fprintf(stderr, "Failed to update data : Error:%s\n", mysql_errno(con));return false;}return true;
}bool StudentManager::delete_student(int student_id) {char sql[256];sprintf_s(sql, "DELETE FROM students WHERE student_id = %d", student_id);if (mysql_query(con, sql)) {fprintf(stderr, "Failed to delete data : Error:%s\n", mysql_errno(con));return false;}return true;
}vector<Student> StudentManager::get_students(string condition) {vector<Student> stuList;char sql[256];sprintf_s(sql, "SELECT * FROM students %s", condition.c_str());if (mysql_query(con, sql)) {fprintf(stderr, "Failed to select data : Error:%s\n", mysql_errno(con));return {};}MYSQL_RES* res = mysql_store_result(con);MYSQL_ROW row;while (row = mysql_fetch_row(res)) {Student stu;stu.student_id = atoi(row[0]);stu.student_name = row[1];stu.class_id = row[2];stuList.emplace_back(stu);}return stuList;
}
// main.cpp
#include "StudentManager.h"int main() {Student stu{999, "彭于晏", "网工1班"};StudentManager::GetInstance()->insert_student(stu);Student stu{999, "彭于晏", "网工3班" };StudentManager::GetInstance()->update_student(stu);StudentManager::GetInstance()->delete_student(1000);vector<Student> ret = StudentManager::GetInstance()->get_students();for (auto& t : ret) {cout << t.student_id << " " << t.student_name << " " << t.class_id << endl;}return 0;
}// main.cpp
#include "StudentManager.h"int main() {StudentManager* studentManager = StudentManager::GetInstance();Student stu1{1009, "彭于晏", "网工1班"};studentManager->insert_student(stu1);Student stu2{999, "胡歌", "网工3班" };studentManager->update_student(stu2);studentManager->delete_student(1001);vector<Student> ret = studentManager->get_students();for (auto& t : ret) {cout << t.student_id << " " << t.student_name << " " << t.class_id << endl;}return 0;
}
http://www.hkea.cn/news/393923/

相关文章:

  • 旅行社网站建设方案论文百度seo公司
  • 长沙网站建设与维护百度开户联系方式
  • 做pcr查基因序列的网站南京百度网站快速优化
  • 数据服务网站策划方案关键词快速优化排名软件
  • 响应式网站缺点学大教育培训机构电话
  • 江苏天德建设工程有限公司网站一个平台怎么推广
  • 石家庄做网络推广的网站推广平台收费标准
  • 贵阳天柱网站建设招聘域名注册平台有哪些
  • 网站建设电话营销百度问一问官网
  • 网站优化建设河南怎么关闭seo综合查询
  • 自贡做响应式网站开发公司google搜索引擎入口google
  • 东莞哪种网站推广好微信朋友圈推广文案
  • 现在学做网站赚钱吗东莞市优速网络科技有限公司
  • 宁津做网站公司宣传推广图片
  • 陕西的建设厅官方网站数据分析报告
  • 企业网站建设的定位互联网
  • 注册域名之后如何做网站优化清理大师
  • wordpress+在线播放推广seo网站
  • 丽水网站建设明恩玉杰网站开发框架
  • 如何设计网站中的上传功能搜索引擎技术基础
  • 余江区建设局网站百度搜索引擎优化的方法
  • 做网站用c 还是java万网域名注册教程
  • 青岛做网站那家好专业的网站优化公司排名
  • 网站如何做淘宝推广seo服务 收费
  • 学完js了可以做哪些网站营业推广的形式包括
  • 网站会员系统怎么做模版seo是指什么职位
  • 上海集团网站制作新闻 近期大事件
  • 商城网站验收标准seo关键词排名优化怎样收费
  • 睢宁做网站公司珠海百度关键字优化
  • 临安市住房和建设局网站伊春seo