473,232 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,232 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 3087
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ricola ! | last post by:
Why do I say: SqlDataReader dr; instead of SqlDataReader dr = new SqlDataReader();
9
by: Jay Douglas | last post by:
Hello, I am needing to pass a class object (this) by reference to a method in a different class. When I do the following code I get the error (Cannot pass '<this>' as a ref or out argument because...
3
by: Neil Guyette | last post by:
Hello, Everyone, I'm trying to find information on how to populate a combo box using a SqlDataReader. I want to be able to set the value of the combo's value property different then the...
1
by: Arvind P Rangan | last post by:
Hi All, How do you get all the values of a sqldatareader if it contains multiple resultset. Using sqldatareader.nextresult and sqldatareader.read e.g. While sqldatareader.read ' If not...
1
by: me | last post by:
Why is SqlDataReader not present in visual studios Toolbox->Data where I find components like DataSet? Most examples in books and in vs.net are based on datasets but using disconnected tables seems...
4
by: mimi | last post by:
Hi Please help me out, I can't find a way to close a sqldatareader when error occur at statement cmd.ExecuteReader(). I can't close it in catch because it is local in try scope and I can't...
7
by: Web learner | last post by:
I am trying to create a method GetDataFor(string column) becaues I have to repeat the same statements for several columns but I get an error as follows: The name 'dr' does not exist in the current...
5
by: =?Utf-8?B?SkI=?= | last post by:
Hello I am passing an arraylist to be filled with data from pgm1 to pgm2 to pgm3 where it gets filled, then I pass it back from pgm3 to pgm2 to pgm1 where I will use the data from arraylist. ...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.