tags:

views:

929

answers:

1

I am using the MYSQL C API and I have a MYSQL_ROW object that I would like to convert to a string. Does anyone know how to do this? I haven't found anything in the API's doc yet.

string str = (string)row[0] <-- runtime error

P.S. I tried casting it to a string but it doesn't work

+1  A: 

Two things:

  1. string isn't a C datatype. You are probably looking for char *.

  2. According to the MySQL API Documentation, MYSQL_ROW isn't null-terminated strings. You should use mysql_fetch_lengths() to copy your desired field to a new string.

staticsan