title: c++ ODBC Connection string
body: <p>In VC++, I used ODBC to connect Database with the following string:</p>
  
  <pre><code>SQLDriverConnect (sqlconnectionhandle, 
               NULL, 
               L"Driver={SQL Server};Server=serverIP, 1433;Database=DBName;Uid=aaa;Pwd=bbb;",
               SQL_NTS, 
               retconstring, 
               1024, 
               NULL,
               SQL_DRIVER_NOPROMPT))
  </code></pre>
  
  <p>my question is how to input the userName and userPw generically withou hardcoding.</p>
  
  <p>Here, L means Unicode.</p>
  
  <p>eg: (this example doesnt work)</p>
  
  <pre><code>SQLWCHAR userName = L"aaa";
  SQLWCHAR userPw = L"bbb";
  SQLWCHAR connString = L"Driver={SQL Server};Server=serverIP, 1433;Database=DBName;Uid=" + userName + ";Pwd=" + userPw + ";",
  </code></pre>
  
  <p>Here is an example for concat strings:(works!)</p>
  
  <pre><code>wchar_t* subString = L" currentDate = '2013-01-04' ";
  
  SQLWCHAR queryString[] = L"select * from Table1 WHERE ";
  wcscat_s(queryString, subString );
  </code></pre>