title: How to connect ado.net database to ASP.Net MVC 5
body: <p>I'm new to ASP.Net MVC 5 and have previously created two applications using ASP.Net Webforms and Ado.Net Database connections.</p>
  
  <p>I've seen many articles explaining how to use Ado.Net connection in ASP.Net MVC, but all the tutorials are using Entity Framework. Is there any way to connect only Ado.Net?</p>
  
  <p>In my WebForm application I've been using this connection code:</p>
  
  <pre><code>connectionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password";
  sql = "SQL Statement";
  cnn = new SqlConnection(connectionString);
  try
  {
      cnn.Open();
      cmd = new SqlCommand(sql, cnn);
      cmd.ExecuteNonQuery();
      cmd.Dispose();
      cnn.Close();
  }
  </code></pre>
  
  <p>Is it possible to use this in ASP .Net MVC5?</p>
  
  <p>When I tried I got this error:</p>
  
  <pre><code>Cannot open database "online_recharge" requested by the login. The login failed.
  Login failed for user 'IIS APPPOOL\DefaultAppPool'.
  </code></pre>
  
  <p>This is the code I tried using:</p>
  
  <pre><code>public ActionResult Add_Balance()
  {
      string record;
  
      using (SqlConnection sqlConnection = new SqlConnection(connectionString))
      {
          sqlConnection.Open();
          SqlCommand sqlCmd = new SqlCommand("Select * from COMMISSION_PACKAGE",sqlConnection);
          SqlDataReader reader = sqlCmd.ExecuteReader();
          record = reader["PKG_NM"].ToString();
          sqlConnection.Close();
      }
  
      ViewBag.Demo = record;
      return View();
  }
  </code></pre>