Hello .
I'm a small VC++ programmer , and I have some problems with mysql c
functions.

What I wanna do , and I don't know how, it's to get an field value from a
table and put it in a char* or into an int

For instance , I have a small table , with two fileds
    name char(50),
    age int(40)


Another thing is to convert the number of the records into a long.

Now , using thoose routines from the documentation:




int main() {
  Connection con("my");
    char * name=new char[50];
    int age;
  Query query = con.query();

  query << "select * from mytable";
  Result res = query.store();


//  cout << "Records Found: " << res.size() << endl << endl;
long records=res.size() :         ?????

  Row row;
  Result::iterator i;
  // The Result class has a read-only Random Access Iterator
  for (i = res.begin(); i != res.end(); i++) {
    row = *i;
    strcpy(name,row["name"];
    age=row["age"];

// do something with name and age here....

  }
delete name;
  return 0;
}



By running this example , my program crashes.

Why ?
And how can I do it right ?






Thanks
                                                                    Alex
Coseru


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to