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.
OracleConnection m_cnn = new OracleConnection("Data Source=MySid;User Id=user1;Password=password1");
m_cnn.Open();
//m_connected = ConnectCDB();
Now I change my code as below and I get an null pointer exception
OracleConnection m_cnn = new OracleConnection("Data Source=MySid;User Id=user1;Password=password1");
//m_cnn.Open();
m_connected = ConnectCDB();
The ConnectCDB function is
private bool ConnectCDB()
{
// Open the database connection
m_cnn.Open();
return true;
}
The m_cnn and m_connected are private members of the class. Why should it give error if I call a separate function?