想用mysql_fetch_row搜索下一行,就删除

每次通过

str.Format(_T("%s"),row[0]);
row=mysql_fetch_row(result);

得到str,然后用

strSQL.Format("delete from mytable where name=\'%s\'",str);
if(mysql_real_query(&mysql,(char*)(LPCTSTR)strSQL,(UINT)strSQL.GetLength())!=0){AfxMessageBox("删除失败");}

这样删除表中内容,为什么一直都是删除失败,如果加上释放内存

 mysql_free_result(result);

只能删除一次,有没有什么好方法可以一直删除下去。

strSQL.Format("delete from mytable where name=\'%s\'",str);
后面下个断点,看看strSQL是什么内容,如果记录已经删除了,或者str包含多余的空格,都不能正确删除。
再看看row[0],这里总是0,如果是循环的话,应该是row[循环索引]