例子:MYSQL* mysql;
......if (mysql_query(mysql, "select name from table where id=1")
{
  MYSQL_RES* result;
  result = mysql_store_result(mysql);
  if (result)
  {
    MYSQL_ROW row;
    row = mysql_fetch_row(result);
    char szName[32] = "White";
    if (strcmp(szName, row[0]) == 0)
      相同
    ......
  }
}

解决方案 »

  1.   

    谢谢小木先   按你的说法我已经实现了
    可我有这样的类   帮我整理一下怎么调用吧
    void DBConn :: ResultSet(MYSQL * conn, MYSQL_RES * res_set)
    {
      MYSQL_ROW row;
      unsigned i;
      while ((row = mysql_fetch_row(res_set))!=NULL)
      {
        for (i=0;i<mysql_num_fields(res_set);i++)
        {
          if (i>0)
             fputc('\t',stdout);
          printf("%s",row[i]!=NULL ? row[i]:"NULL");
          fputc('\n',stdout);
        }
        if (mysql_errno(conn)!=0)
        {
          printf("myslq_fetch_row() failed");
        }
        else
          printf("%lu rows returned\n",(unsigned long)mysql_num_rows(res_set));
      }//end while
    }
    void DBConn :: Query(MYSQL *conn,char *query)
    {
      unsigned int field_count;
      if (mysql_query(conn,query)!=0)
      {
        printf("process_query() failed\n");
        return;
      }
      res_set = mysql_store_result(conn);
      if (res_set == NULL)
      {
        if (mysql_field_count(conn)>0)
        {
          printf("problem processing result set ");
        }
        else
        {
          printf("%lu rows affected\n",(unsigned long)mysql_affected_rows(conn));
        }
      }
      else
      {
        DBConn dbconn;       //连接数据库的类声明
        dbconn.ResultSet(conn,res_set);
        mysql_free_result(res_set);
      }
    }
      

  2.   

    呵呵,你这个类只提供了演示功能!它就是教你怎么使用C APIMYSQL* conn;
    ....DBConn dbconn;
    dbconn.Query(conn, "SELECT * FROM tbl_name");结果:
    打印出tbl_name表的所有记录的所有字段的值我自己封装了一个类,比较简单,但一般应用已经构了,你给我个email,我发给你!
      

  3.   

    竟然今天才看见,谢谢小木,希望你能够给我发来,我的email:[email protected]
      

  4.   

    [email protected]
    GIRL?????
    老兄。好像是女生也。
    恭喜!
      

  5.   

    to huahua0168(huahua):已经给你发过去了!
      

  6.   

    顺便给俺也发一个吧,谢谢!
    [email protected]
      

  7.   

    呵呵,是吗,我给你们两个都发邮件了,可是hotmail都回复我没有发成功!疑惑中~~~接口比较少,也比较简单,不过只要适合就行了,我看了很多遍mysql手册C API的内容,实践过程中慢慢也就积累了一些经验!
      

  8.   

    啊呀,不好意思,我把我自己的邮箱写错了,难怪没有收到,麻烦小木再发一次吧。
    再次抱歉!
    [email protected]