How to use a datareader instead of a dataset?

S

Shapper

Hello,

I have this ASP.NET / VB code which uses a dataset:
----
For Each row As DataRow In dsContent("index").Tables(0).Rows
Dim div As HtmlGenericControl =
CType(Page.FindControl(row("name").ToString), HtmlGenericControl)
If row("content").ToString <> "" Then
div.InnerHtml = row("content").ToString
Else
div.InnerHtml = "&nbsp;"
End If
Next
----

How can I change this code to use a DataReader names drContent instead
of dsContent?

I am having problems with the "For" loop and then with the "row".

Thank You,
Miguel
 
G

Glen Wilkin via DotNetMonster.com

while(ldrReader.Read())
{
string lstrVal = ldrReader["ColName"].ToString();
}
ldrReader.Close();
 
S

Shapper

Hi,

I am having some problems. Could you tell me how the following two lines
would become?

Dim div As HtmlGenericControl =
CType(Page.FindControl(drContent("name").ToString), HtmlGenericControl)

If drContent("content").ToString <> "" Then

Note - In my original code when I do:

....dsContent("index")...

I am accessing my DataGrid function and get the records which [page]
field value is equal to "index".

When I use

....row("name").ToString...

I am accessing the [name] field value of a certain record.

Anyway, the "While drContent.Read()" is working, as I changed it to
"While drContent("index").Read()" but the rest it's not.

Thanks,
Miguel
 

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
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top