0
我正在使用此代碼從數據表中找出最近的值。應用程序在循環之間凍結
For Each row As DataGridViewRow In DataGridView2.Rows
ToolStripProgressBar1.Value = ToolStripProgressBar1.Value + 1
f = 0
Using dbconnn As New OleDbConnection(connString)
dbconnn.Open()
While f <> 1
Dim query1 As String = "Select [Alloted_Operator], [Avg_Eff] from ASkill_Matrix2 where [Operation_Type] = '" & row.Cells("Operation_Type").Value & "' and [Avg_Eff] between " & Double.Parse(row.Cells("Req_perf").Value - a) & " and " & Double.Parse(row.Cells("Req_perf").Value + a) & " and [Alloted_Operator] not in (select All_Opr from A) "
Using cmd As New OleDbCommand(query1, dbconnn)
Using reader1 = cmd.ExecuteReader
'If reader1.HasRows Then
If reader1.Read() Then
f = 1
'MessageBox.Show(i)
row.Cells("All_Opr").Value = reader1.GetValue(0)
row.Cells("Opr_Eff").Value = reader1.GetValue(1)
row.Cells("Exp_Prod").Value = Convert.ToDouble((60 * row.Cells("Opr_Eff").Value)/(row.Cells("Oprn_SAM").Value * 100))
row.Cells("Balance").Value = Convert.ToInt64(row.Cells("Exp_Prod").Value - Convert.ToInt64(Label1.Text))
row.Cells("Rem_Eff").Value = Convert.ToInt64(row.Cells("Opr_Eff").Value - row.Cells("Req_perf").Value)
Dim query29 As String = "insert into A ([Machine_Type], [Attatchment], [All_Opr]) Values ('" & CStr(row.Cells("Machine_Type").Value) & "', '" & CStr(row.Cells("Attatchment").Value) & "', '" & CStr(row.Cells("All_Opr").Value) & "')"
Using cmd1 As New OleDbCommand(query29, dbconnn)
cmd1.ExecuteNonQuery()
End Using
If row.Cells("Rem_Eff").Value >= 20 Then
Dim query3 As String = "insert into Temp_Av_Opr ([Machine_Type], [Attatchment], [All_Opr],[Opr_Eff]) Values ('" & CStr(row.Cells("Machine_Type").Value) & "','" & CStr(row.Cells("Attatchment").Value) & "', '" & CStr(row.Cells("All_Opr").Value) & "', '" & CStr(row.Cells("Rem_Eff").Value) & "')"
Using cmd2 As New OleDbCommand(query3, dbconnn)
cmd2.ExecuteNonQuery()
End Using
End If
Else
a += 1
End If
End Using
End Using
End While
End Using
Next
,這是我的凍結窗口在第二次運行應用
請幫我在這或PLZ建議我任何其他方法來這樣做。 謝謝