Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 13th, 2004, 02:33 PM
Registered User
 
Join Date: Sep 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need Help!!!

hi
i am getting an error - Collection was modified; enumeration operation may not execute
it point son the next in my loop
i have to make it work!!
here is the code

For Each row In dt.Rows


                number = row.ItemArray(0)
                cmd2.CommandText = "select * from Pays where PhoneNumberFrom ='" & number & "'"
                cmd2.Connection = con
                cmd2.CommandType = CommandType.Text

                con.Open()
                Try
                    Dim adp2 As New OleDbDataAdapter(cmd2)
                    adp2.Fill(dt)
                Catch

                End Try
                con.Close()
                DataGrid2.DataSource = dt
                DataGrid2.DataBind()

        Next

thanks tali


 
Old September 14th, 2004, 12:16 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You have a for each on dt.rows...
then in the for, you are modifying dt.

Perhaps you need a second DataTable object.
 
Old September 15th, 2004, 12:07 AM
Registered User
 
Join Date: Sep 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to heroman
Default

if you are using the datatable object
you can't change it

Study,Progress,Life...
 
Old September 15th, 2004, 07:51 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

If the results are already in the data table, use a data view to extract the current record.

Brian
 
Old September 23rd, 2004, 10:53 PM
Authorized User
 
Join Date: Jul 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you need 2 loops. Build a array of number cycle your table once then do the loop you wrote.
The code you have is modifying the loop's collection.
You can't modify dt and use dt in the loop condition.

 
Old October 17th, 2004, 10:54 AM
Registered User
 
Join Date: Apr 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am studying¡­¡­










Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.