title: SqlException: Deadlock
body: <p>I have these two exceptions generated when I try to get data from SQL database in C#:</p>
  
  <blockquote>
    <p>System.Data.SqlClient.SqlException:  Transaction (Process ID 97) was deadlocked on lock resources with another process and has been chosen as the deadlock victim.</p>
  </blockquote>
  
  <p>OR </p>
  
  <blockquote>
    <p>System.Data.SqlClient.SqlException: Transaction (Process ID 62) was deadlocked on lock resources with another process and has been chosen as the deadlock victim.</p>
  </blockquote>
  
  <p>OR</p>
  
  <blockquote>
    <p>System.Data.SqlClient.SqlException: Transaction (Process ID 54) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.</p>
  </blockquote>
  
  <p>this is the code:</p>
  
  <pre><code> using (SqlConnection con = new SqlConnection(datasource))
   {
      SqlCommand cmd = new SqlCommand("Select * from MyTable Where ID='1' ", con);
      cmd.CommandTimeout = 300;
      con.Open();
      SqlDataAdapter adapter = new SqlDataAdapter(cmd);
      DataSet ds = new DataSet();
      adapter.Fill(ds);
      con.Close();
      return ds.Tables[0];
   }
  </code></pre>
  
  <p>These happened every time.</p>
  
  <p>Any ideas on how these can be resolved?</p>