Skip to content

Commit 082c0d6

Browse files
authored
Merge pull request #3887 from DanielAdeniji/patch-8
Update sqlbindcol-function.md
2 parents 650a25e + b05cf6c commit 082c0d6

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

docs/odbc/reference/syntax/sqlbindcol-function.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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
294294
void 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

Comments
 (0)