title: retrieving data using prepared statements in C#
body: <p>i have a table with 3 columns(EmpId,EmpName,EmpSalary).
  i am using a prepared statement to retrieve all the data from this table using prepared statement.
  here is what i have written...</p>
  
  <pre><code>try
          {
              SqlCommand cmd = con.CreateCommand();
              cmd.CommandText = "SELECT EmpId,EmpName,EmpSalary FROM EmpDetails";
  
              SqlParameter paraId = new SqlParameter();
              paraId.ParameterName = "@id";
              paraId.SqlDbType = SqlDbType.Int;
              paraId.Size = 32;
  
  
              SqlParameter paraName = new SqlParameter();
              paraName.ParameterName = "@name";
              paraName.SqlDbType = SqlDbType.VarChar;
              paraName.Size = 50;
  
              SqlParameter paraSal = new SqlParameter();
              paraSal.ParameterName = "@sal";
              paraSal.SqlDbType = SqlDbType.Decimal;
              paraSal.Precision = 7;
              paraSal.Scale = 2;
  
              cmd.Parameters.Add(paraId);
              cmd.Parameters.Add(paraName);
              cmd.Parameters.Add(paraSal);
  
              con.Open();
              cmd.Prepare();
              SqlDataReader dr = cmd.ExecuteReader();
              string str = "";
              while(dr.Read())
              {
                  string id = dr.GetInt32(0).ToString();
                  string name = dr.GetString(1);
                  string sal = dr.IsDBNull(2) ? "is null" : dr.GetDecimal(2).ToString();
                  str += id + "\t" + name + "\t" + sal + "\n";
              }
              MessageBox.Show(str);
  
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message);
          }
          finally
          {
              if (con.State == ConnectionState.Open)
                  con.Close();
          }
  </code></pre>
  
  <p>but i am getting an error as follows :
  "The parameterized Query expects the parameter @id , which was not supplied."</p>
  
  <p>What mistake am i doing here..??</p>