操作mysql莫名崩溃

随心而动随意而行 2014-07-30 05:16:43
m_pMysql = mysql_init(m_pMysql);

if (m_pMysql==NULL)
{
return false;
}

if(mysql_real_connect(m_pMysql,t_DBIp,t_DBUser,t_DBPasswd,t_DBName,t_DBPort,NULL,0))
{
if (mysql_query(m_pMysql,"set names utf8;")==0)
{
cout<<"OK"<<endl;
}

}

MYSQL_STMT *m_pStmt;

MYSQL_BIND m_ParamBind[8];
int t_store[8];
my_bool is_null[8];
const char *error = NULL;

memset( m_ParamBind ,0, sizeof(m_ParamBind) );
memset( t_store ,0, sizeof(t_store) );

//memset( is_null ,0, sizeof(is_null) );

n32 err = 0;
n8 quary[] = "call insert_dailytasks(?,?,?,?,?,?,?,?)";

for (int i=0; i<8; ++i)
{
t_store[i] = 10;
}
for (int a_nIdx=1; a_nIdx<8; ++a_nIdx)
{
m_ParamBind[a_nIdx].buffer = (void*)&t_store[a_nIdx];
m_ParamBind[a_nIdx].buffer_type = MYSQL_TYPE_LONG;
m_ParamBind[a_nIdx].is_null = &is_null[a_nIdx];
m_ParamBind[a_nIdx].length = 0;
is_null[a_nIdx] = 0;
}

unsigned long long t_RoleID = 578;

m_ParamBind[0].buffer_type = MYSQL_TYPE_LONGLONG;
m_ParamBind[0].buffer = (void*)&t_RoleID;
m_ParamBind[0].is_null = &is_null[0];
is_null[0] = 0;


m_pStmt = mysql_stmt_init(m_pMysql);

mysql_stmt_prepare(m_pStmt,quary,strlen(quary));


mysql_stmt_param_count(m_pStmt);



mysql_stmt_bind_param(m_pStmt, m_ParamBind);

//一执行到下面的语句就崩溃

mysql_stmt_execute(m_pStmt);
...全文
125 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
已解决,谢谢啦.
ACMAIN_CHM 2014-07-30
  • 打赏
  • 举报
回复
错误提示是什么? 另外最好监控一下错误时的m_pStmt实际内容是什么?

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧