title: Oracle connection in ASP.NET
body: <p>I have a ASP.NET (.NET 4.0) application which implements Rest Services. I am connecting to Oracle in this application. My code works fine as under. Please note its in the constructor.</p>
  
  <pre><code>OracleConnection m_cnn = new OracleConnection("Data Source=MySid;User Id=user1;Password=password1");
  m_cnn.Open();
  //m_connected = ConnectCDB();
  </code></pre>
  
  <p>Now I change my code as below and I get an null pointer exception</p>
  
  <pre><code>OracleConnection m_cnn = new OracleConnection("Data Source=MySid;User Id=user1;Password=password1");
  //m_cnn.Open();
  m_connected = ConnectCDB();
  </code></pre>
  
  <p>The ConnectCDB function is</p>
  
  <pre><code>private bool ConnectCDB()
  {
     // Open the database connection
     m_cnn.Open();
  
     return true;
  }
  </code></pre>
  
  <p>The m_cnn and m_connected are private members of the class. Why should it give error if I call a separate function?</p>