views:

49

answers:

0

For table creation and insertion i am using these string.

Create table mystudents(sname varchar(50),sno varchar(25),mark1 numeric,mark2 numeric);
insert into mystudents values('lala','tk001',100,100);

int status = mysql_query(hnd,sql);
    if (status)
    {
      printf("Could not execute statement(s)");
      mysql_close(hnd);
      //exit(0);
    }
    int lIntRow=0;
    MYSQL_RES *result=NULL;
    MYSQL_ROW row; // one row returned
    int numfield=0;
     // process each statement result 

      result = mysql_store_result(hnd);
      if (result)
      {
     // yes; process rows and free the result set 
     //process_result_set(hnd, result);
            if (result) 
      {
       row = mysql_fetch_row(result); 
       numfield = mysql_num_fields(result);    
      }
      else
      {
       //fprintf(stderr,"Failed to use the result acquired!\n"); 
       return 0;
      }
      mysql_free_result(result);
      }
      else          // no result set or error
      {
     if (mysql_field_count(hnd) == 0)
     {
      printf("%lld rows affected\n",
       mysql_affected_rows(hnd));
     }
     else  // some error occurred
     {
       printf("Could not retrieve result set\n");
       break;
     }
      }

while I try to get details from table my using the above C++ code I am getting values 1542852 or 14253689 instead of 1 from mysql_num_fields.