出现 can't send long data for non-string/non-binary data type;
char buf[1000];
unsigned char devdata[10]={0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0x10};
unsigned long length;
mysql_init(&mysql);
if(mysql_real_connect(&mysql,"localhost","root","1",NULL,3306,NULL,NULL))
{
}
if(mysql_query(&mysql,"create database if not exists test;"))
{
}
if(mysql_query(&mysql,"create table if not exists test.devdata(devid int PRIMARY key not null,UICU TEXT not null);"))
{
}
sprintf_s(buf,"insert into test.devdata(devid,UICU) values('258',?);");
stmt=mysql_stmt_init(&mysql);
if (!stmt)
{
MessageBox("1");
}
if(mysql_stmt_prepare(stmt, buf, sizeof(buf)))
{
MessageBox("a");
}
memset(sqlbind, 0, sizeof(sqlbind));
sqlbind[0].buffer_type =MYSQL_TYPE_STRING;
sqlbind[0].length = &length;
sqlbind[0].is_null=0;
if (mysql_stmt_bind_param(stmt, sqlbind))
{
MessageBox("b");
}
if (mysql_stmt_send_long_data(stmt, 0, "MYSQL", 5))
{
CString a;
a.Format("%d,%s",mysql_stmt_errno(stmt),mysql_stmt_error(stmt));
MessageBox(a);
}
if (mysql_stmt_execute(stmt))
{
MessageBox("d");
}
char buf[1000];
unsigned char devdata[10]={0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0x10};
unsigned long length;
mysql_init(&mysql);
if(mysql_real_connect(&mysql,"localhost","root","1",NULL,3306,NULL,NULL))
{
}
if(mysql_query(&mysql,"create database if not exists test;"))
{
}
if(mysql_query(&mysql,"create table if not exists test.devdata(devid int PRIMARY key not null,UICU TEXT not null);"))
{
}
sprintf_s(buf,"insert into test.devdata(devid,UICU) values('258',?);");
stmt=mysql_stmt_init(&mysql);
if (!stmt)
{
MessageBox("1");
}
if(mysql_stmt_prepare(stmt, buf, sizeof(buf)))
{
MessageBox("a");
}
memset(sqlbind, 0, sizeof(sqlbind));
sqlbind[0].buffer_type =MYSQL_TYPE_STRING;
sqlbind[0].length = &length;
sqlbind[0].is_null=0;
if (mysql_stmt_bind_param(stmt, sqlbind))
{
MessageBox("b");
}
if (mysql_stmt_send_long_data(stmt, 0, "MYSQL", 5))
{
CString a;
a.Format("%d,%s",mysql_stmt_errno(stmt),mysql_stmt_error(stmt));
MessageBox(a);
}
if (mysql_stmt_execute(stmt))
{
MessageBox("d");
}