30-07-14, 09:48 AM
السلام عليكم
هل ممكن التعديل على هذا الكود
هذا الكود وظيفته عرض البيانات من الدتا بيز فى treeview
لاكن الكود يأخذ وقت طويل فى اظهار البيانات فيظهر البيانات متتابعة بسبب استخدام جملة for
هل ممكن تعديل الكود ليتم عرض جميع البيانات مباشرة دون انتظار ؟
هل ممكن التعديل على هذا الكود
كود :
Dim word As String = encrypt(TextBox5.Text.Trim)
Dim a As String = Format(DateTimePicker1.Text, "dd/mm/yyyy")
' Using databch As New OleDbDataAdapter("SELECT * FROM low6 where a6 like '%" & word & "%' and a3= '" & TextEdit6.Text.Trim & "' and a4= '" & TextEdit5.Text.Trim & "'", ConStr)
Dim sql As String = String.Format("SELECT distinct a2 FROM low6 where a6 like '%{0}%'", word)
If String.IsNullOrEmpty(TextBox6.Text.Trim) Then
sql = sql
Else
sql = String.Format("{0} and a3= '{1}'", sql, TextBox6.Text.Trim)
End If
If String.IsNullOrEmpty(TextBox7.Text.Trim) Then
sql = sql
Else
sql = String.Format("{0} and a4= '{1}'", sql, TextBox7.Text.Trim)
End If
If String.IsNullOrEmpty(DateTimePicker1.Text.Trim) Or String.IsNullOrEmpty(DateTimePicker2.Text.Trim) Then
sql = sql
Else
sql = String.Format("{0}and a5 >= #{1}# and a5 <= #{2}#", sql, DateTimePicker1.Text.Trim, DateTimePicker2.Text.Trim)
End If
Dim datasrech As New DataSet
Dim datasrech2 As New DataSet
Label9.Text = "0"
Using databch As New OleDbDataAdapter(sql, ConStr1)
datasrech.Clear()
databch.Fill(datasrech, "treserch")
If Me.BindingContext(datasrech, "treserch").Count = 0 Then
TreeView5.Nodes.Clear()
MsgBox("لم يتم العثور على شيء", 48 + 524288, "البحث")
Exit Sub
End If
Label9.Visible = True
Label9.Text = Me.BindingContext(datasrech, "treserch").Count
End Using
ProgressBar1.Visible = True
ProgressBar1.Minimum = 0
ProgressBar1.Maximum = Val(Label9.Text) + 1
ProgressBar1.Value = 0
Dim dv1 As DataView = datasrech.Tables("treserch").DefaultView
TreeView5.Nodes.Clear()
For Each drLine As DataRowView In dv1
Dim id_sharh As Integer = drLine("a2").ToString
Using datab4 As New OleDbDataAdapter("SELECT * FROM low5 where id = " & id_sharh & "", ConStr1)
datasrech2.Clear()
datab4.Fill(datasrech2, "low5")
Dim dv12 As DataView = datasrech2.Tables("low5").DefaultView
For Each drLine2 As DataRowView In dv12
Dim MainHeader As New TreeNode(drLine2("a6").ToString())
MainHeader.Tag = drLine2("key").ToString
MainHeader.Name = drLine2("key").ToString
' MainHeader.ForeColor = Color.Red
TreeView5.Nodes.Add(MainHeader)
Application.DoEvents()
Next
End Using
Next
TreeView5.EndUpdate()
لاكن الكود يأخذ وقت طويل فى اظهار البيانات فيظهر البيانات متتابعة بسبب استخدام جملة for
هل ممكن تعديل الكود ليتم عرض جميع البيانات مباشرة دون انتظار ؟