title: failed to connect to database using c#
body: <p>I want to ask about connecting db with c#.
  I have read <a href="http://csharp.net-informations.com/data-providers/csharp-sql-server-connection.htm" rel="nofollow noreferrer">http://csharp.net-informations.com/data-providers/csharp-sql-server-connection.htm</a> and written my code, but the connection doesn't seem to be working.</p>
  
  <p>This is my code:</p>
  
  <pre><code>string connetionString = null;
  SqlConnection connection;
  SqlCommand command;
  string sql = null;
  SqlDataReader dataReader;
  connetionString = "Data Source=localhost;Initial Catalog=dbabc;User ID=admin;Password=qwerty";
  sql = "UPDATE ppd,brg,cmp SET WHERE";
  connection = new SqlConnection(connetionString);
  try
  {
      connection.Open();
      command = new SqlCommand(sql, connection);
      dataReader = command.ExecuteReader();
      while (dataReader.Read())
      {
          MessageBox.Show(dataReader.GetValue(0) + " - " + dataReader.GetValue(1) + " - " + dataReader.GetValue(2));
      }
      dataReader.Close();
      command.Dispose();
      connection.Close();
  }
  catch (Exception ex)
  {
      MessageBox.Show("Can not open connection ! ");
  }
  </code></pre>
  
  <p>Did I write something wrong? The error message shown always says "Can not open connection"!</p>