时间:2021-07-01 10:21:17 帮助过:151人阅读
MYSQL m_sqlCon;
mysql_init(&m_sqlCon);
if(!mysql_real_connect(&m_sqlCon,"localhost","root","0412qwer","xscj",3306,NULL,0))
{AfxMessageBox(_T("数据库连接失败"));}
else
{AfxMessageBox(_T("数据库连接成功"));}
string sqlstr; string str1("sas"); string str2("dfsd"); int result; sqlstr="insert into xs(XH,XM) values('"+str1+"','"+str2+"')"; result=mysql_query(&m_sqlCon,sqlstr.c_str()); if(0!=result) mysql_close(&m_sqlCon);