VS2010 MFC +mySQL 连接,添加,查询,删除,修改【代码】

找了好久终于找到相关的了,分享一下,为了实现数据库的修改功能

https://blog.csdn.net/sheng_bw/article/details/89739615

CString m_id ,m_name,m_salary ;
GetDlgItemText(IDC_EDIT1,m_id);
GetDlgItemText(IDC_EDIT2,m_name);
GetDlgItemText(IDC_EDIT3,m_salary);
//MYSQL mysqlCon;
// 创建 SQL 语句字符串
CString sql_insert;
sql_insert.Format(_T(“UPDATE tw SET name =’%s’ WHERE id = ‘%s’;”),m_name,m_id);
USES_CONVERSION;
LPCSTR lpstr = (LPCSTR)T2A(sql_insert);
int ress = mysql_query(&mysqlCon, lpstr);
if (ress == 0)
{
MessageBox(_T(“修改成功”));
}
else
{
MessageBox(_T(“修改失败”));
}

你可能感兴趣的:(MFC,数据库)