[QUOTE=born star;1196745][U][I]how does highlighted lines work............. [/I][/U]

[CODE] public List<clsproductprp> RetAllCol_rec()
List<clsproductprp> obj = new List<clsproductprp>();
SqlDataReader dr=null;
SqlCommand discmd = new SqlCommand();
if (con.State == ConnectionState.Closed)

             discmd.CommandText = "spDisplayALLProduct";
             discmd.CommandType = CommandType.StoredProcedure;
             discmd.Connection = con;

            [COLOR="red"][B] dr = discmd.ExecuteReader();[/B][/COLOR]

             while (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());
                [B][COLOR="red"] obj.Add(prp);[/COLOR][/B]
         catch { }
         return obj;

the ExecuteReader method of the Command object executes the command and creates the Reader object, which now contains your data. This works in a read-only, forward-only way, storing all your data in a buffer. Then each row is read while there are still rows to read. You may wish to check that the reader contains something before you attempt to read, using something like [CODE]if(dr.HasRows())[/CODE]. It looks like properties of a retrieved row are assigned to an object and that object is added to the List obj by the lower highlighted line.
Here is a link that may also help:

I am facing problem in connection of sql server in asp.net pages
Actually there is error when i importing namespace [B]System.Data.Sqlclient[/B]
Error is:[/B]
The type or namespace name 'sqlclient' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)

now i don't idea that what s this how to remove this error
Currently i am using VS2010 ,MSSQL server 2005 Express edition[/QUOTE]

You may have discovered this already, but i believe namespaces are case sensative. The namespace you are looking for may be [B]System.Data.SqlClient[/B] I hope this helps.

nirveshverma commented: thanks it's working now +0