Hi,
Another question, I am using mysql database and on starting a prog I check to see whether the database is available or not, if not available then give some error message otherwise keep the database open and then close it at the end of the prog.
I am making the db connection as follows
My question is how can I pass this connection handle to another programme which executes some sql queries, the function I am calling is
this particular function is in logmsg.cpp.
How can I pass the db connection handle to this routine.
Thanks for any help
tewari
Another question, I am using mysql database and on starting a prog I check to see whether the database is available or not, if not available then give some error message otherwise keep the database open and then close it at the end of the prog.
I am making the db connection as follows
Code:
conn = mysql_init (NULL);
if (conn == NULL)
{
fprintf (stderr, "mysql_init() failed (probably out of memory)\n");
}
if (mysql_real_connect (
conn, /* pointer to connection handler */
m_dbHost.c_str(), /* host to connect to */
m_dbUser.c_str(), /* user name */
m_dbPass.c_str(), /* password */
m_dbDatabase.c_str(), /* database to use */
0, /* port (use default) */
NULL, /* socket (use default) */
0) /* flags (none) */
== NULL)
{
fprintf (stderr, "mysql_real_connect() failed:\nError %u (%s)\n",
mysql_errno (conn), mysql_error (conn));
Code:
// Creating LogMsg object in main()"
LogMsg logmsg;
logmsg.updateDatabase(m_envelopTo, m_envelopFrom, m_getDateTime, m_Size, m_headerFrom, m_headerTo, m_subject, m_messageID, m_fileName, m_dispositionStr, conn);
How can I pass the db connection handle to this routine.
Thanks for any help
tewari