List:MySQL++« Previous MessageNext Message »
From:Chris Frey Date:May 25 2005 7:43pm
Subject:Re: Can you have more than one active mysqlpp::Connection object?
View as plain text  
On Wed, May 25, 2005 at 11:37:07AM -0700, Earl Miles wrote:
> From looking this over, I think your problem might be string manipulation.
> 
> const char *text = row[1];
> 
> I'm not sure row[] is guaranteed to return a null terminated string. 
> Without a null terminator, strlen() is guaranteed to fail and fail 
> badly. I believe what you really want is this (slightly longer than it 
> has to be for clarity):
> 
> std::string tempString = row[1];
> const char *test = tempString.c_str();

Yep, Earl is on the right track.  See the declaration of operator[] in
row.h:

const ColData   operator [] (size_type i) const;

This returns a temporary, which disappears after that line of code.
You need to make a copy for yourself.

- Chris

Thread
Can you have more than one active mysqlpp::Connection object?Byrial Jensen24 May
  • Re: Can you have more than one active mysqlpp::Connection object?Earl Miles24 May
  • Re: Can you have more than one active mysqlpp::Connection object?Warren Young24 May
    • Re: Can you have more than one active mysqlpp::Connection object?Byrial Jensen25 May
      • Re: Can you have more than one active mysqlpp::Connection object?Earl Miles25 May
        • Re: Can you have more than one active mysqlpp::Connection object?Chris Frey25 May
          • Re: Can you have more than one active mysqlpp::Connection object?Chris Frey25 May
            • Re: Can you have more than one active mysqlpp::Connection object?Earl Miles25 May
          • Re: Can you have more than one active mysqlpp::Connection object?Byrial Jensen25 May
            • Re: Can you have more than one active mysqlpp::Connection object?Warren Young26 May
              • Re: Can you have more than one active mysqlpp::Connection object?Byrial Jensen26 May
                • Re: Can you have more than one active mysqlpp::Connection object?Warren Young26 May