title: Error CS0136 A local or parameter named '...' cannot be declared in this scope because that name is used in an enclosing local scope
body: <p>This is an error message :</p>
  <blockquote>
  <p>Error  CS0136  A local or parameter named 'cmd' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter  Ayubo_Car_Rental_System D:\Education File\Visual Studio\Ayubo Car Rental&quot;</p>
  </blockquote>
  <p>This is my code:</p>
  <pre><code>              try
                  {
                      Sqlconn.Open();
  
                      SqlCommand cmd = Sqlconn.CreateCommand();
                      cmd.CommandType = CommandType.Text;
  
                      cmd.CommandText = &quot;Select * from Rent&quot;;
  
                      cmd.ExecuteNonQuery();
  
                      SqlDataAdapter SDA = new SqlDataAdapter(cmd);
                      DataTable DT = new DataTable();
  
                      SDA.Fill(DT);
                      dataGridView1.DataSource = DT;
  
                      Sqlconn.Close();
                  }
  
                  catch (Exception EX)
                  {
                      MessageBox.Show(&quot;Error&quot; + EX);
                  }
  </code></pre>