Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Need Help with DataReader. Thanks.

Reply
Thread Tools

Need Help with DataReader. Thanks.

 
 
Shapper
Guest
Posts: n/a
 
      05-05-2005
Hello,

I created a code in VB which fills div's in HTML with content stored in
a database using a dataset:

' Populate Dynamic Content Div's
For Each row As DataRow In dsContent("index").Tables(0).Rows
Dim div As HtmlGenericControl = CType(Page.FindControl("d" &
row("name").ToString), HtmlGenericControl)
If row("content_" & Session("culture")).ToString <> "" Then
div.InnerHtml = row("content_" & Session("culture")).ToString
Else
div.InnerHtml = "&nbsp;"
End If
Next

I am having huge problems in making this work with a datareader.

It's not just the "For" loop but also the code line:
CType(Page.FindControl("d" & row("name").ToString), HtmlGenericControl)

Can someone help me out?

Thank You,
Miguel

 
Reply With Quote
 
 
 
 
Angrez Singh
Guest
Posts: n/a
 
      05-05-2005
Hi,

If you want to do this with data reader you can't have a for loop like
that. That is fine if you are using a dataset.

If you are using a datareader then perhaps you should write your loop
like....

// dr is datareader and read function returns true or false depending
upon if there are
// rows left or not.
while(dr.Read())
{
// do your job here.
}

HTH,

Regards,
Angrez

 
Reply With Quote
 
 
 
 
Patrick Olurotimi Ige
Guest
Posts: n/a
 
      05-05-2005
And make sure u don't close the Reader before calling it



*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Help, I am intermediate in Java...need help in follow case ElementX Java 9 10-01-2008 08:02 PM
Help Help. I really need some help with this =?Utf-8?B?Q2hyaXM=?= ASP .Net 3 01-31-2007 09:33 PM
re_---need help Network Adapters!!!! NEED HELP!!!! hedayatniac@gmail.com Computer Support 4 08-13-2006 01:03 AM
Need help! I need to add lead zeros to a textbox Teep ASP .Net 2 06-21-2004 01:04 PM
Please help!!! Need datagrid selection to fill textboxes...Need quick!! TN Bella ASP .Net 1 06-18-2004 01:31 AM



Advertisments