Question: PostgreSQL needs to be used in VC. ODBC is used in the first place. I want to use other methods because I feel the configuration is troublesome. We can see that libpq ++ can be used at the beginning, but the version of libpqxx is no longer available after. Others also say that libpqxx is used, but those makefiles are hard to get, it seems that a specific vs version is required for compilation, so libpq is used in simplicity, because only simple functions are used.
Problem description: PostgreSQL: declare cursor failed: Error: Invalid byte sequence for encoding "utf8": 0xc9e3
Cause: because the Chinese table name is used, the SELECT statement also has Chinese characters. When constructing strsql, cstring and cstring are ASCII encoded, even if _ T ("") is added as Unicode encoding, you must convert it to utf8 to pqexec () or change the table name to English.
BTW: int nres = pqsetclientencoding (Conn, "SQL _ascii"); // sets the client encoding.
Const char * chcode = pg_encoding_to_char (pqclientencoding (conn); // view the client Encoding
This document is not easy to understand.