471,853 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,853 software developers and data experts.

How to pass SqlDataReader row

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.
Nov 19 '05 #1
3 3033
have you tried using DataRow as an argument to the 'BuildProduct' procedure
and then in loop through the columns.
"msnews" <an******@yahoo.com> wrote in message
news:uX*************@TK2MSFTNGP10.phx.gbl...
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.

Nov 19 '05 #2
prod.GetValues?

Ray at work

"msnews" <an******@yahoo.com> wrote in message
news:uX*************@TK2MSFTNGP10.phx.gbl...
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.

Nov 19 '05 #3
msnews wrote:
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!
Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Ricola ! | last post: by
9 posts views Thread by Jay Douglas | last post: by
3 posts views Thread by Neil Guyette | last post: by
1 post views Thread by Arvind P Rangan | last post: by
1 post views Thread by me | last post: by
5 posts views Thread by =?Utf-8?B?SkI=?= | last post: by
NeoPa
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.