Hi, this questions looks really easy but I'm a noob in C++ and MySQL so it still doesn't work.
Here is the deal: I have a string (_bstr_t) that contains the xml and I want to store it in a longblolb column in MySql.
Ways I tried that failed:
- write my xml on a local file and use mysql command LOAD_FILE, this worked localy but not on the server, and it is not secure to use this method with a server
- use mysql_real_escape_string() I think ist the way to go but this function takes char* and I have multibyte string so it doesn't work
Are there other ways to store a xml in MySQL or is there a function like mysql_real_escape for multibyte.
The strcpy dosen't work it gives me "Access violation reading location..." When I tried the cast it look good but finaly I had a MySql error:
"Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?xml version=\"1.0\" encoding=\"UTF-16\"?>\r\n XVision_Objects noNamespaceSchem' at line 1"
And finaly, for the first solution you gave me, i'm really new to C++ and I don't know where to put the ::char*, I'm not able to compile.
char *to = new char[xml.length() * 2 + 1];
char* from = (char*)xml::char*;
mysql_real_escape_string(conn,to,from,xml.length());
thank you very much for your help!