How to modify a value in one of the field while fetching MySQL???
Posted by: Surgey Pushkin
Date: August 17, 2011 12:29AM

Hi, I have tried many things, did not work, what I need is to modify MediumINT Column while fetching MySQL. But it fails! Here is the code:

MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;

char *server = "hostlocal.com";
char *user = "myuser_name";
char *password = "password"; /* set me first */
char *database = "database1";
conn = mysql_init(NULL);

while ( !mysql_real_connect(conn, server,user, password, database, 0, NULL, 0) )
{ ::MessageBox(HWND_DESKTOP,"Cannot connect to MySql","Help",MB_OK);
::MessageBox(HWND_DESKTOP,"To Resolve, Fix Internet Connection or Credentials!","Help",MB_OK);
}

int ip = mysql_query(conn,"SELECT * FROM Student_Database");

res = mysql_use_result(conn);

long row_num = 0;

if (ip==0)
while ((row = mysql_fetch_row(res)) != NULL)
{

char * row_s;
_itoa(row_num,row_s,strlen(row_s)+1);

row[5] = row_s; // Here I want to modify the value.

/* HERE I have a column name "Count",which is INTMEDIUM, which I would want to modify, as I fetch the numbers of the rows from 0,1,2,3... and so on...*/
/* I would want to place 0,1,2,and so on... BUT ii fails!, I have 6 fields, row[0],row[1],row[2],row[3],row[4],row[5] want to modify the last one. */

row_num++;
}

mysql_free_result(res);
mysql_close(conn);


Any body know how this can be done???

Options: ReplyQuote


Subject
Views
Written By
Posted
How to modify a value in one of the field while fetching MySQL???
3443
August 17, 2011 12:29AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.