OleDbConnection not found while using System.data namespace in code
<p>In my code, I am using OleDbConnection. When I refer to System.Data, it gives me the error that OleDbConnection is not found. But when I refer to System.Data.OleDb namespace then it runs fine.
Why is this error occurring?
I checked for the reference via add reference path for System.Data and it exist.</p>
<hr />
<p>Find the below code for better clearance:</p>
<pre><code>using System.Data;

public partial class Home : System.Web.UI.Page
{
  OleDbConnection oledbconn;
  protected void Page_Load(object sender, EventArgs e)
  {

  }
}
</code></pre>
<p>In above code, <strong>OleDbConnection oledbconn;</strong>---This line no 4 gives error that</p>
<p><strong>Type or namespace OleDbConnection cannot be found</strong></p>
<p>And now consider the following code,</p>
<pre><code>using System.Data.OleDb;

public partial class Home : System.Web.UI.Page
{
    OleDbConnection oledbconn;
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}
</code></pre>
<p>Here the code works fine,</p>
<p>I know that adding OleDb to System.Data will resolve my issue but I want to know why does it gives error in first place even if I have referred to System.Data namespace,</p>
<p>According to my knowing, when I refer to System.Data, it indirectly refer to all his child elements like OleDb, SqlClient and all..isn't it?</p>