Looping and managed strings

I have a Visual C++ Windowed project that I do some mysql queries with and then loop through the results to put into a textBox. It goes something like this.

1
2
3
4
while (row = mysql_fetch_array(res)) {
  String ^ mystring = gcnew String(row[0]);
  textBox1->Text = mystring;
}


The value of row[0] will either be a char or string.

The managed side of it requires the strings to be System::String, while the mysql queries and results are std::string or char. So, I have to convert them inside the loop.

I understand that the strings are gc'd when they go out of scope, but I know I shouldn't be creating it like this.

What's a more proper way to do this ?
Topic archived. No new replies allowed.