Home > Software engineering >  For help! MFC variable how to write data in MySQL?
For help! MFC variable how to write data in MySQL?

Time:11-08

As I defined in MFC variables: cstrings STR. int num; Double dou;
MySQL built table (car) : name (varchar), number1 (int), number1 (double);
When writing data, I use the statements as follows:
char SQL [300];
Sprintf_s (SQL, "INSERT INTO the car (name, number1, number1) VALUES (' % s', '% d', '% f')", STR, num, dou);

But insert failed,,,

CodePudding user response:

String type field to quotes'
Numbers don't add quotation marks

CodePudding user response:

Not written into the Chinese string, insert, database encoding utf8, why

CodePudding user response:

refer to the second floor weixin_45669978 response:
written into the Chinese string, insert, the database encoding utf8, why

String is designed for first utf8

CodePudding user response:

Modify the connection drive character set

CodePudding user response:

Why, sprintf_s statement cstrings types should be converted to char *, I can only read the first character

CodePudding user response:

MySQL is utf8 encoding, MFC is Unicode, then how to change

CodePudding user response:

Well, must first put cstrings type into a char * type, use T2A
  • Related