Private Sub BackgroundWorker1_DoWork(sender As Object, e As DoWorkEventArgs) Handles BackgroundWorker1.DoWork Dim Obj As RetriveTableData = DirectCast(e.Argument, RetriveTableData) Dim SqlcmdString As String = "" Dim DT As DataTable Dim i As Integer = 1 Dim ds As DataSet Dim dr As DataRow Try Using conn As New SqlConnection(ConnString) Using Sqlcmd As New SqlCommand("Query", conn) Sqlcmd.CommandType = CommandType.Text Using adapter As New SqlDataAdapter(Sqlcmd) Using ds As New DataSet DT = ds.Tables(0) If DT.Rows.Count > 0 Then - (Error After This Line) For Each dr As DataRow In DT.Rows convert.toint32(adapter[""].ToString()); Obj.sceneID = dr("ID").ToString() Obj.Quality = dr("Quality").ToString() adapter.Fill(DT) DataGridView1.DataSource = DT Thread.Sleep(100) To Report progress. BackgroundWorker1.ReportProgress(i, Obj) If BackgroundWorker1.CancellationPending Then Set the e.Cancel flag so that the WorkerCompleted event knows that the process was cancelled. e.Cancel = True BackgroundWorker1.ReportProgress(0) Return End If i += 1 Next End If End Using End Using End Using End Using Catch ex As Exception MessageBox.Show(ex.Message) End Try end sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)