can somebody tell me how does data reader work in following list
and what will the result of............if(dr.Read())..
public List<clsproductprp> RetFind_rec(clsproductprp prp1)
{
SqlDataReader dr=null;
List<clsproductprp> obj = new List<clsproductprp>();
SqlCommand discmd = new SqlCommand();
try
{
if (con.State == ConnectionState.Closed)
{
con.Open();
}
discmd.CommandText = "spFindFromProduct";
discmd.CommandType = CommandType.StoredProcedure;
discmd.Connection = con;
discmd.Parameters.AddWithValue("@fanProductid", prp1.productidprp);
dr = discmd.ExecuteReader();
if(dr.Read())
{
clsproductprp prp = new clsproductprp();
prp.productnameprp = dr["Producname"].ToString();
prp.Quantityperunitprp = Convert.ToInt32(dr["Quantityperunit"].ToString());
prp.unitinStockprp = Convert.ToInt32(dr["unitinstock"].ToString());
prp.unitPriceprp = Convert.ToInt32(dr["unitPrice"].ToString());
prp.productidprp = Convert.ToInt32(dr["Productid"].ToString());
obj.Add(prp);
}
}
catch { }
finally
{
dr.Close();
discmd.Dispose();
}
return obj;
}