Hi,

I'm new to the database and ODBC world and I have a question.
When I run the following code I get the error below. I googled and searched around, which said my connection might be lost or my query is too big. But neither of those cases are true. I'm wondering if anyone can find the mistake in my code.

THANKS!!!

Michelle



*************** ERROR ***********************************
mainSQLState HY000
MySQL server has gone away
*************** ERROR ***********************************




*************** CODE BEGINS******************************
// Insert Query
void cDatabase::Insert(void)
{
SQLRETURN rc = SQL_SUCCESS;

// used for SQLGetDiagRec
SQLINTEGER NativeError;
SQLCHAR SQLState[6];
SQLCHAR ErrorMsg[255];
SQLSMALLINT ErrorMsgLength;

// query statement
SQLCHAR* statement = (SQLCHAR*)"Insert into dummy values ('2004-01-09')";

// allocate a SQL statement handle
rc = SQLAllocHandle(SQL_HANDLE_STMT, m_hDbc, &m_hStmt);
printf("allocating SQL statement handle\n");

if (rc == SQL_SUCCESS)
{
// rc=SQLPrepare(m_hStmt, statement, 39);
rc=SQLExecDirect(m_hStmt, statement, SQL_NTS);

// rc=SQLExecute(m_hStmt);

if (rc == SQL_SUCCESS)
printf("insert successful!\n");
if (rc == SQL_ERROR)
{
printf("insert unsuccessful! Error!\n");
SQLGetDiagRec(SQL_HANDLE_STMT, m_hStmt, 1, SQLState, &NativeError, ErrorMsg, 255, &ErrorMsgLength);
printf("mainSQLState %s\n", SQLState);
printf("%s\n\n", ErrorMsg);
}
}
}

*************** CODE ENDS******************************