[Help] Fail to insert binary to database
Posted by: Lennon Lam
Date: November 09, 2011 05:29AM

Dear all,

I met a problem when i wanna insert binary to database. I've spent a lot of time to solve it but i still cannot find any solution......

My problem is, when i insert binary by binding it to statement and execute the query. The steps report no error. However, only NULL is inserted to database. (if i set the column to Not-NULL, 0 is inserted instead)\

Here is my work flow:

    sprintf_s(query, 2048, "INSERT INTO Person(Name) VALUES(?)");

    if (mysql_stmt_prepare(stmt, query, strlen(query)))
        return -1;


    MYSQL_BIND bind[1];
    memset(bind, 0, sizeof(bind));
    unsigned long size = strlen(personName);
    bind[0].buffer_type = MYSQL_TYPE_VAR_STRING;
    bind[0].buffer = (char *)personName;
    bind[0].length = &size;
    bind[0].is_null = (my_bool*)0;

    if (mysql_stmt_bind_param(stmt, bind))
        return -1;


    if (mysql_stmt_execute(stmt))
        return -1;

Have anyone met something like this?? Any suggestion is appreciated!!

Thanks!!!!!!!

Options: ReplyQuote


Subject
Views
Written By
Posted
[Help] Fail to insert binary to database
1206
November 09, 2011 05:29AM


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.