How to pass SqlDataReader row

M

msnews

Hi All,

I have the following code

------------------------------------------------
Business.Prod prod = new Business.Prod();
SqlDataReader Product = prod.GetProducts();

while (prod.Read())
{
Response.Write(BuildProduct("PASS THE ROW");
}


private string BuildProduct("ACCEPT ROW")
{
//"READ COLUMNS IN ROW"
}
------------------------------------------

Basically, I want to read every row and pass it to the BuildProduct method.
I am not sure how to pass the row, accept it and read the columns.

Please help.

Thanks in Advance.
 
V

Vaibhav

have you tried using DataRow as an argument to the 'BuildProduct' procedure
and then in loop through the columns.
 
F

Fabio Marini

msnews said:
while (prod.Read())
{
Response.Write(BuildProduct("PASS THE ROW");
}

Try:
while (prod.Read())
{
Response.Write(BuildProduct(prod);
}
private string BuildProduct("ACCEPT ROW")
{
//"READ COLUMNS IN ROW"
}

and:
private string BuildProduct(IDataReader dr)
{
// return value in column called col1
return dr["col1"].ToString();
}

Have fun!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top