troubleshooting Question

Datagridview error

Avatar of RIAS
RIASFlag for United Kingdom of Great Britain and Northern Ireland asked on
Visual Basic.NET.NET Programming
23 Comments1 Solution160 ViewsLast Modified:
I get an error :
Row provided does not belong to this DataGridView control.
Parameter name: e.Row

 If con.State = ConnectionState.Closed Then
                End If
                com.Connection = con
                DataGridView1.VirtualMode = False
                'Commented out for messsage queue load on the server
                If DataGridView1.Rows.Count > 0 Then
                    'Commented out for messsage queue load on the server
                    For Each rw As DataGridViewRow In DataGridView1.Rows

                        com.CommandText = ("insert query" )

                        count = com.ExecuteNonQuery()
                        'Commented  for messsage queue load on the server
                        'Commented  for messsage queue load on the server

                        'Objwriter.WriteLine("Total Rows:" + count.ToString)

                        com.CommandTimeout = 725

                        Success = True
                End If

Open in new window

Freelance programmer / Consultant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 23 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 23 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros