MySQL Forums
Forum List  »  Chinese

使用mysql_stm_bind_result函数出现运行时错误
Posted by: fangwen liu
Date: October 27, 2011 07:12PM

这是我的代码:

#include "stdafx.h"
#include "mysql.h"
#define STRSELECT "select * from test1"
#pragma comment(lib,"libmysql.lib")

int _tmain(int argc, _TCHAR* argv[])
{
MYSQL sql;
MYSQL_STMT *stmt;
MYSQL_BIND bind[1];
int int_data;
MYSQL_BIND res[1];
MYSQL_ROW row;
mysql_init(&sql);
if(!mysql_real_connect(&sql,"localhost","root","b@dme3tEv1l","test",3306,0,0))
{
fprintf_s(stdout,"unable to connect host");
exit(1);
}
stmt=mysql_stmt_init(&sql);
mysql_stmt_prepare(stmt,STRSELECT,strlen(STRSELECT));
memset(bind, 0, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_LONG;
bind[0].buffer= (char *)&int_data;
bind[0].is_null= 0;
bind[0].length= 0;
mysql_stmt_execute(stmt);
int i=mysql_stmt_field_count(stmt);
int j=mysql_stmt_param_count(stmt);
mysql_stmt_bind_result(stmt,bind);
while(mysql_stmt_fetch(stmt))
{
printf_s("1=%d",int_data);
}
getchar();
return 0;
}


运行到mysql_stmt_bind_result的时候总弹出断言错误 libmysql.c 4320 行 DBUG_ASSERT(param->buffer_length != 0);

但查阅过源文件这一行断言不会在bind[0].buffer_type= MYSQL_TYPE_LONG;的时候运行啊,,

目前百思不得其解~~~

Options: ReplyQuote


Subject
Views
Written By
Posted
使用mysql_stm_bind_result函数出现运行时错误
5886
October 27, 2011 07:12PM


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.