title: MFC connect to sql server with ODBC
body: <p>I have a SDI MFC and I want to use CDatabase to connect to a remote SQL server.</p>
  
  <p>I've created a ODBC connection in my computer, and the DSN is 'TodoTest'.</p>
  
  <p>Here is my code.</p>
  
  <pre><code>CDatabase db;
  CString connStr = _T("DSN=TodoTest;");
  if (!db.OpenEx(connStr, CDatabase::openReadOnly))
  {
      // Failed to connect to database.
      return;
  }
  CRecordset rs(&amp;db);
  ......
  </code></pre>
  
  <p>The question is it seems OpenEx() has been suspended forever, because I can not see any return value of it, and the code never runs to the subsequent lines.</p>
  
  <p>The program is frozen.</p>
  
  <p>Should I include any other information in the connection string?</p>
  
  <p>Thanks.</p>