title: Ado.net Sql Connection
body: <p>I try to make Sql connection using Ado.Net. I create a ConsoleApplication and get the <code>Name</code> and <code>UnitPrice</code> values from my database. After execution Console says can not open a connection. What is wrong that I make ?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Data.SqlClient;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  class ConsoleApplication1
  {
      static void Main()
      {
          string connectionString =
              "Data Source=EMINCIFTCI/EMIN;Initial Catalog=Ado;User ID=sa;Password=10203040";
  
  
          string queryString =
              "SELECT Name, UnitPrice from dbo.Product "   
                  + "ORDER BY UnitPrice DESC;";
  
          using (SqlConnection connection =
              new SqlConnection(connectionString))
          {
  
              SqlCommand command = new SqlCommand(queryString, connection);
  
              try
              {
                  connection.Open();
                  SqlDataReader reader = command.ExecuteReader();
                  while (reader.Read())
                  {
                      Console.WriteLine("\t{0}\t{1}",
                          reader[0], reader[1]);
                  }
                  reader.Close();
              }
              catch (Exception ex)
              {
                  Console.WriteLine(ex.Message);
              }
              Console.ReadLine();
          }
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/dcNHt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dcNHt.jpg" alt="My Database"></a></p>