报错:插入 is failure ,error is :Incorrect string value: '\xF0\xC2!\xED2\x01' for column 'sname' at row 1
代码:#include
#include
#include
#include
#include"windows.h"
#include
#include
using namespace std;
int main(){
MYSQL mysql;
mysql_init(&mysql);
int t = 100;
string a = "ticke";
if (!mysql_real_connect(&mysql, "localhost", "root", "hsy1019", "studentmanage", 3306, NULL, 0))
{
cout << "\n数据库连接发生错误";
return 0;
}
else
cout << "connect successfully";
int i = 0;
//int res;
char query[100];
cout << "学生信息为 学号 姓名" << "\n";
sprintf_s(query, "insert into studentg(sno,sname) values('%d','%s')", t,a);
if (mysql_query(&mysql, query))
fprintf(stderr, "插入 is failure ,error is :%s\n", mysql_error(&mysql));
else
puts("插入 success!");
//res = mysql_query(&mysql, "insert into studentg(sno,sname) values(stu[i].id,stu[i].name");
mysql_close(&mysql);
system("pause");
return 1;
}