MySQL Forums
Forum List  »  Connector/C++

getString() is returning (null)
Posted by: Sushi Fish
Date: January 01, 2010 07:44AM

Im sorry if there alleady is a topic like that. i didnt find it then :\

I try to get some string from my database using getString but when ever i try to get the string getString returns (null) but there is definitly somthing in my database.
Im using version 1.0.5 of the connector and my database is version 5.1
Is there something special with character set or something i need to know??

my code looks like this:
-----------------------------------------------------------
// Connect to database
data->sql_data->connect();

// update account data
char buf[512];
str_format(buf, sizeof(buf), "UPDATE %s_account SET last_logged_in=NOW() WHERE ID='%d'", data->sql_data->prefix, data->account_id);
data->sql_data->statement->execute(buf);

// get account name from database
str_format(buf, sizeof(buf), "SELECT Name FROM %s_account WHERE ID='%d';", data->sql_data->prefix, data->account_id);
dbg_msg("SQL", "ID: %d", data->account_id);
// create results
data->sql_data->results = data->sql_data->statement->executeQuery(buf);

// jump to result
data->sql_data->results->next();

// finally save the account name
std::string acc_name = data->sql_data->results->getString(1);

dbg_msg("SQL", "Account '%s' was saved successfully", acc_name);

// delete statement and results
delete data->sql_data->statement;
delete data->sql_data->results;

// disconnect from database
data->sql_data->disconnect();
------------------------------------------------

in the database the requested files is defined as VARCHAR with latin1_german1_ci character set.

I hope someone can help me.



Edited 1 time(s). Last edit at 01/01/2010 07:59AM by Sushi Fish.

Options: ReplyQuote


Subject
Views
Written By
Posted
getString() is returning (null)
6522
January 01, 2010 07:44AM
2412
January 01, 2010 08:31AM
2639
January 03, 2010 07:32PM
2387
January 04, 2010 05:04AM
2346
March 31, 2010 06:16AM


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.