CString strUsername,strList,strRemark,strSQL; strSQL.Format("insert into mytable(username,visitelist,remark) values(\''%s\'',\''%s\'',\''%s\'')", strUsername,strList,strRemark);//注意一定要写在一行,而且必须要有\''\'' if(mysql_real_query(&mysql,(char*)(LPCTSTR)strSQL,(UINT)strSQL.GetLength())!=0){ AfxMessageBox("增添失败"); }
CString strUsername,strList,strRemark,strSQL,str_PreName;//str_PreName用于记录想要修改的行,详情请看源代码 strSQL.Format("update mytable set username=\''%s\'',visitelist=\''%s\'', remark=\''%s\'' where username=\''%s\''",strUsername,strList,strRemark,str_PreName); if(mysql_real_query(&mysql,(char*)(LPCTSTR)strSQL,(UINT)strSQL.GetLength())!=0){ AfxMessageBox("修改失败"); }