Note that there are some explanatory texts on larger screens.

plurals
  1. POwriting a byte array to mysql using c connector?
    primarykey
    data
    text
    <p>is there any smart way to write a byte array into varbinary or (other explain me) im looking to make funciton like that</p> <pre><code> bool writeBinary(char * someQuery, LPBYTE buffer) { } </code></pre> <p>when i using next function the data that happend in mysql not same to the buffer</p> <pre><code>void CDBManager::SetBinary(const char * lpszStatement, LPBYTE lpBinaryBuffer, ULONG BinaryBufferSize) { MYSQL_STMT *stmt; MYSQL_BIND bind[1]; char * shhh = new char[BinaryBufferSize]; // ---- memcpy(shhh, lpBinaryBuffer, BinaryBufferSize); stmt = mysql_stmt_init(&amp;getDB()-&gt;m_hMySQL); printf("\n"); if(BinaryBufferSize &gt;= 2752) { for(int i = 0; i &lt; BinaryBufferSize; i++) { if(lpBinaryBuffer[i] == 0xFF &amp;&amp; lpBinaryBuffer[i+1] == 0xFF &amp;&amp; lpBinaryBuffer[i+2] == 0xFF &amp;&amp; lpBinaryBuffer[i+3] == 0xFF &amp;&amp; lpBinaryBuffer[i+4] == 0xFF &amp;&amp; lpBinaryBuffer[i+5] == 0xFF &amp;&amp; lpBinaryBuffer[i+6] == 0xFF &amp;&amp; lpBinaryBuffer[i+7] == 0xFF &amp;&amp; lpBinaryBuffer[i+8] == 0xFF &amp;&amp; lpBinaryBuffer[i+9] == 0xFF &amp;&amp; lpBinaryBuffer[i+10] == 0xFF &amp;&amp; lpBinaryBuffer[i+11] == 0xFF &amp;&amp; lpBinaryBuffer[i+12] == 0xFF &amp;&amp; lpBinaryBuffer[i+13] == 0xFF &amp;&amp; lpBinaryBuffer[i+14] == 0xFF &amp;&amp; lpBinaryBuffer[i+15] == 0xFF) { } else { printf("[%d] %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", i, lpBinaryBuffer[i], lpBinaryBuffer[i+1], lpBinaryBuffer[i+2], lpBinaryBuffer[i+3], lpBinaryBuffer[i+4], lpBinaryBuffer[i+5], lpBinaryBuffer[i+6], lpBinaryBuffer[i+7], lpBinaryBuffer[i+8], lpBinaryBuffer[i+9], lpBinaryBuffer[i+10], lpBinaryBuffer[i+11], lpBinaryBuffer[i+12], lpBinaryBuffer[i+13], lpBinaryBuffer[i+14], lpBinaryBuffer[i+15]); } i+=15; } } printf("\n"); if(stmt == NULL) { fprintf(stderr, " mysql_stmt_init(), out of memory\n"); } else if(mysql_stmt_prepare(stmt, lpszStatement, strlen(lpszStatement))) { fprintf(stderr, " mysql_stmt_prepare(), INSERT failed\n"); fprintf(stderr, " %s\n", mysql_stmt_error(stmt)); } else { memset(bind, 0, sizeof(bind)); // ---- bind[0].buffer_type = MYSQL_TYPE_BLOB; bind[0].buffer = (char *)shhh; bind[0].buffer_length = BinaryBufferSize; bind[0].is_null = 0; bind[0].length = 0; // ---- // allways filed? what? this calls they are good, i made by example on mysql.com so what dont work // it always return len 0 =&gt; no data saved in db if(mysql_stmt_bind_param(stmt, bind)) { fprintf(stderr, " mysql_stmt_bind_param() failed\n"); fprintf(stderr, " %s\n", mysql_stmt_error(stmt)); } else if(mysql_stmt_execute(stmt)) { fprintf(stderr, " mysql_stmt_execute(), 1 failed\n"); fprintf(stderr, " %s\n", mysql_stmt_error(stmt)); } } // ---- delete shhh; </code></pre> <p>}</p> <p>thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload