How to pass SqlDataReader row

  • Thread starter Thread starter msnews
  • Start date Start date
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.
 
have you tried using DataRow as an argument to the 'BuildProduct' procedure
and then in loop through the columns.
 
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

Back
Top