@@ -289,7 +289,7 @@ SQLRETURN SQLBindCol(
289289#include <sqlext.h>
290290
291291#define NAME_LEN 50
292- #define PHONE_LEN 20
292+ #define PHONE_LEN 60
293293
294294void show_error() {
295295 printf("error\n");
@@ -329,17 +329,24 @@ int main() {
329329 if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
330330
331331 // Bind columns 1, 2, and 3
332- retcode = SQLBindCol(hstmt, 1, SQL_C_CHAR , &sCustID, 100, &cbCustID);
333- retcode = SQLBindCol(hstmt, 2, SQL_C_CHAR , szName, NAME_LEN, &cbName);
334- retcode = SQLBindCol(hstmt, 3, SQL_C_CHAR , szPhone, PHONE_LEN, &cbPhone);
332+ retcode = SQLBindCol(hstmt, 1, SQL_C_WCHAR , &sCustID, 100, &cbCustID);
333+ retcode = SQLBindCol(hstmt, 2, SQL_C_WCHAR , szName, NAME_LEN, &cbName);
334+ retcode = SQLBindCol(hstmt, 3, SQL_C_WCHAR , szPhone, PHONE_LEN, &cbPhone);
335335
336336 // Fetch and print each row of data. On an error, display a message and exit.
337- for (i ; ; i++) {
337+ for (int i=0 ; ; i++) {
338338 retcode = SQLFetch(hstmt);
339339 if (retcode == SQL_ERROR || retcode == SQL_SUCCESS_WITH_INFO)
340340 show_error();
341341 if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
342- wprintf(L"%d: %S %S %S\n", i + 1, sCustID, szName, szPhone);
342+ {
343+ //replace wprintf with printf
344+ //%S with %ls
345+ //warning C4477: 'wprintf' : format string '%S' requires an argument of type 'char *'
346+ //but variadic argument 2 has type 'SQLWCHAR *'
347+ //wprintf(L"%d: %S %S %S\n", i + 1, sCustID, szName, szPhone);
348+ printf("%d: %ls %ls %ls\n", i + 1, sCustID, szName, szPhone);
349+ }
343350 else
344351 break;
345352 }
0 commit comments