Collection was modified?
Collection was modified?
Collection was modified?
Collection was modified?
Collection was modified?
Collection was modified? Collection was modified? Collection was modified? Collection was modified? Collection was modified? Collection was modified? Collection was modified? Collection was modified?
Collection was modified? Collection was modified?
Collection was modified?
Go Back  Xtreme Visual Basic Talk > > > Collection was modified?


Reply
 
Thread Tools Display Modes
  #1  
Old 09-20-2008, 04:02 PM
mesaexplorerbc1 mesaexplorerbc1 is offline
Regular
 
Join Date: Jan 2004
Location: Gresham, OR
Posts: 61
Default Collection was modified?


Can someone help me out with why this code generates the error:
"Collection was modified; enumeration operation may not execute."

I don't see how I am modifying the collection.

Code:
<%
        Dim ATsSQL As String = "SELECT * FROM AssetTypes"
        Dim ATSQLConn As String = "Data Source=XX.XX.XX.XX\SQLEXPRESS;Initial Catalog=J2_DB;User ID=XXX;Password=XXX;Integrated Security=False"
        
        Dim DBConn As New Data.SqlClient.SqlConnection(ATSQLConn)
        Dim DBCommand = New Data.SqlClient.SqlCommand(ATsSQL, DBConn)

        DBConn.Open()
        Dim DBReader As Data.SqlClient.SqlDataReader = DBCommand.ExecuteReader()

        Response.Write("<fiedset><legend>Current Asset Types</legend><table><tr><td></td><td>ID</td><td>Name</td><td>S/N Req'd?</td></tr>")

        While DBReader.Read()

            Response.Write("<tr><td>")
            Dim cmdButton As New Button
            cmdButton.Text = "Edit"
            cmdButton.ID = DBReader("ID").ToString
            AddHandler cmdButton.Click, AddressOf EditClick
            Page.Controls.Add(cmdButton)
            Response.Write("</td><td>" & DBReader("ID").ToString & "</td><td>" & DBReader("Name").ToString & "</td><td>" & DBReader("SerialNoRequired").ToString & "</td></tr>")

        End While

        Response.Write("</table></fieldset>")
        
        %>
Reply With Quote
  #2  
Old 09-20-2008, 09:33 PM
HorrorGamer HorrorGamer is offline
Regular
 
Join Date: Aug 2008
Location: Surprise, AZ
Posts: 89
Default

It looks like the only collection modified was the Page.Controls.
__________________
Play Tank Games
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Collection was modified?
Collection was modified?
Collection was modified? Collection was modified?
Collection was modified?
Collection was modified?
Collection was modified? Collection was modified? Collection was modified? Collection was modified? Collection was modified? Collection was modified? Collection was modified?
Collection was modified?
Collection was modified?
 
Collection was modified?
Collection was modified?
 
-->