Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat to pass as the ColumnSize argument of ODBC SQLBindParameter in a C/C++ program?
    primarykey
    data
    text
    <p>I am learning how to use the <code>SQLBindParameter</code> function. I was going through a couple of examples on the Internet and it is not clear what I should be passing as the 6th argument to the <code>SQLBindParameter</code> function.</p> <p>The example at <a href="http://msdn.microsoft.com/en-us/library/ms710963(v=vs.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms710963(v=vs.85).aspx</a> passes the size of the character array when the C type is <code>SQL_C_CHAR</code> and 0 when the C type is <code>SQL_C_SSHORT</code>.</p> <pre><code>SQLSMALLINT sCustID; SQLCHAR szEmployeeID[EMPLOYEE_ID_LEN]; SQL_DATE_STRUCT dsOrderDate; SQLINTEGER cbCustID = 0, cbOrderDate = 0, cbEmployeeID = SQL_NTS; </code></pre> <p>...</p> <pre><code>retcode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, EMPLOYEE_ID_LEN, 0, szEmployeeID, 0, &amp;cbEmployeeID); retcode = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &amp;sCustID, 0, &amp;cbCustID); </code></pre> <p>However, an example at <a href="http://publib.boulder.ibm.com/infocenter/db2e/v8r2/index.jsp?topic=%2Fcom.ibm.db2e.doc%2Fdbeapc1702.html" rel="nofollow">http://publib.boulder.ibm.com/infocenter/db2e/v8r2/index.jsp?topic=%2Fcom.ibm.db2e.doc%2Fdbeapc1702.html</a> passes 0 for SQL_C_TCHAR and some positive integers for SQL_C_LONG.</p> <pre><code>long p1 = 10; short p2 = 100; TCHAR p3[100]; </code></pre> <p>...</p> <pre><code>// bind input parameters rc = SQLBindParameter(hstmt, (unsigned short)1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 4, 0, &amp;p1, sizeof(p1), &amp;len); // check return code ... rc = SQLBindParameter(hstmt, (unsigned short)2, SQL_PARAM_INPUT, SQL_C_LONG, SQL_SMALLINT, 2, 0, &amp;p2, sizeof(p2), &amp;len); // check return code ... len = SQL_NTS; rc = SQLBindParameter(hstmt, (unsigned short)3, SQL_PARAM_INPUT, SQL_C_TCHAR, SQL_CHAR, 0, 0, &amp;p3[0], 100, &amp;len); </code></pre> <p>Could someone please clarify how exactly do we decide the parameters to be passed into <code>SQLBindParameter</code>?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload