List:MySQL++« Previous MessageNext Message »
From:Ibrahim Mubarak Date:December 29 2004 8:50pm
Subject:Re: Query Execution
View as plain text  
--- Mysql Plusplus <mysql_mailbox@stripped> wrote:

> Hi Everybody,
> I have a problem while accessing MySQL database from a C++ program. Can anyone help
> me please.
> We execute query as:
> mysql_query(conn,"SELECT * FROM employee");
> where conn is the MYSQL *, and employee is the table name.
> If we have department in char *dept. Then how can we put the pointer value in the
> query? For
> example if we want to execute the following query how will we do it:
> SELECT Names FROM employee WHERE Department = 'IT';
> And IT is stored in char *dept.

hmmm. You might want to check the examples on the different ways you can execute queries.
But here
is how I would do it (showing the essential only):

mysqlpp::Connection conn(mysqlpp::use_exceptions);
conn.connect("user_name", "host", "database_name", "password");
mysqlpp::Query query = conn.query();

query << "SELECT Names FROM employee WHERE Department=\"" << dept
mysqlpp::Result res = query->store();

To retrieve the info, you need to use the Row object, which is used just like a STL
class (list, etc.). For this, I won't give you the answer :). Check the examples. Check
complic1.cpp in particular. It has all you need.

> Any help will be appreciated.
> Thank You.
> And may all u have a very Happy New Year.

You too ;)


Do you Yahoo!? 
Jazz up your holiday email with celebrity designs. Learn more.
Query ExecutionMysql Plusplus29 Dec
  • Re: Query ExecutionIbrahim Mubarak29 Dec
  • Re: Query ExecutionWarren Young30 Dec