Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / May 2008

Tip: Looking for answers? Try searching our database.

Invalid attempt to call FieldCount when reader is closed

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mark.norgate@gmail.com - 20 May 2008 09:40 GMT
Hi

I have a problem with a repeater and a data connection.

In my Page_Load, I have the following code:

               Dim connectionString As String =
WebConfig.ConnectionString
               Dim connection As SqlConnection = New
SqlConnection(connectionString)
               Dim adapter As SqlDataAdapter = New
SqlDataAdapter("SELECT applicationID FROM pvtProductApplication WHERE
productID = " + Request.QueryString("prodId"), connection)
               Dim dataSet As DataSet = New DataSet()
               connection.Open()
               adapter.Fill(dataSet)
               ApplicationRepeater.DataSource = dataSet
               ApplicationRepeater.DataBind() /* error here */
               connection.Close()

and I have a ApplicationRepeater_ItemCreated that also opens a data
connection and closes it. The error is raised as indicated above.

Can someone please help??

Thanks, Mark
Teemu Keiski - 20 May 2008 20:38 GMT
Hi,

are these operations (this and the one in ItemCreated) sharing the same
connection object, which would get closed unexpectedly?

You don't need to optimize that way (sharing one connection on the page)
necessarily, since connection pooling in .NET will mostly take care of that
e.g it will get you connections efficiently and reuse them. Of course if
there could be numerous of conenction object creations, that's another thing

And with DataAdapters' you don't need to open the connection first before
calling Fill, it is opened for you.

Anyways, to give more exact advice, can you show the code in ItemCreated
using the connection?

Signature

Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

> Hi
>
[quoted text clipped - 22 lines]
>
> Thanks, Mark

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.