Solving using C/C++ to configure ODBC link returns -1 using SQLConnect

When creating an empty project in VS and using an ODBC connection, the SQLConnect function always returns -1, and mysql and command line connections to the database are no problem

retcode = SQLConnect(hdbc, (SQLCHAR*)"test", SQL_NTS, (SQLCHAR*)"root", SQL_NTS, (SQLCHAR*)"", SQL_NTS);

It turns out that because my mysql is 64-bit installed, the ODBC setting is also 64-bit, and then the compiler in vs is 32-bit, so just change the compilation to 64-bit, as shown in the figure:

On the right side of DEBUG, click on x86

Select the configuration manager, enter, and change it to x64 in the platform.

After the change is completed, compile again, the system appears ""SQLCHAR *" type actual parameter "SQLWCHAR *" type parameter is not compatible" error (¬︿̫̿¬☆)

The solution to this problem is:

In Debug--Properties--General--Character Set, set it to multi-byte character set

After this step is changed, debug and run again, the debugging is successful, and sqlconnect also returns 0.

success

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325380085&siteId=291194637