title: How to SQLBindParameter for INSERT Statement correctly?
body: <p>I want to insert Data in an SQl database with odbc. The target column has datatype varchar( 20 ). When i'm now insert data with following code, there are trailing whitespaces if the data is shorter then 20 characters:</p>
  
  <pre><code>#define     TEST_NAME_LEN   20
  
  SQLINTEGER  lenret;
  char        data_buf[ TEST_NAME_LEN ];
  
  .
  .
  .
  lenret = SQL_NTS;
  
  SQLBindParameter( hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, TEST_NAME_LEN, 0, data_buf, 0, &amp;lenret );
  
  SQLPrepare( hstmt, (SQLCHAR*)"INSERT INTO test VALUES ( ? )", SQL_NTS );
  
  strcpy( data_buf, "hello" );
  
  SQLExecute( hstmt );
  
  </code></pre>
  
  <p>Now in the database the value looks like <code>&gt;hello               &lt;</code>, filled up with 15 spaces.</p>
  
  <p>How is it done that there is only the "hello" in the db?
  Example was taken from <a href="https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlbindparameter-function?view=sql-server-2017" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlbindparameter-function?view=sql-server-2017</a></p>