How to store control characters in MySQL DB through C++ code?
<p>I have a requirement. In my project I need to store control characters (ASCII characters range from 0 to 31). But here I need to store in the form of characters. I wrote a c code, but it not worked. I'm posting here the code what I wrote.
My IDE is Visual Studio 2010 and I'm using MySQL Connector C 6.0.2  </p>

<pre><code>     #include "stdafx.h"
     #include &lt;iostream&gt;
     #include &lt;string&gt;
     #include&lt;my_global.h&gt; 
     #include &lt;mysql.h&gt;

     using namespace std;

     MYSQL* Connection, MySQL;

int _tmain(int argc, _TCHAR* argv[])
{
int i;
string sData;
char SQLString[384];

for(i=0;i&lt;=31;i++)
    sData+=i;

    char *Hostname="localhost", *Username="root", *Password="system123", *Database="file_data"; 

mysql_init(&amp;MySQL);
Connection = mysql_real_connect(&amp;MySQL, Hostname, Username, Password, Database, 0, 0, 0);

if (Connection == NULL)
    exit(1);

sprintf_s(SQLString,384,"set sql_mode='NO_BACKSLASH_ESCAPES';");    
mysql_query(Connection, SQLString );

sprintf_s(SQLString,384,"insert into file_values(first_data)values('%s')",sData.c_str());
mysql_query(Connection, SQLString );
    return 0;
    }
</code></pre>

<p>Here, before writing actual project code, I wrote a sample application to test is it able to store or not, but by using above code I'm not able to store the control characters in first_data column of file_values table.</p>

<p>The data type of first_data is varchar of size 33.</p>

<p>Plz let me know the changes what I need to do in above code to acheive my requirement.</p>

<p>Thanks one and all.</p>
